Skip to content

Commit

Permalink
Merge pull request #96 from DerOetzi/modules_power
Browse files Browse the repository at this point in the history
Add power_today field
  • Loading branch information
DerOetzi authored Jul 23, 2024
2 parents 7b5229c + 8a82596 commit 554569a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion solaredge2mqtt/services/monitoring/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from datetime import datetime

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, computed_field


class LogicalInfo(BaseModel):
Expand Down Expand Up @@ -36,3 +36,13 @@ class LogicalModule(BaseModel):
info: LogicalInfo
energy: float | None = Field(None)
power: dict[datetime, float] | None = Field(None)

@computed_field
@property
def power_today(self) -> dict[str, float] | None:
power_today = None

if self.power:
power_today = {k.strftime("%H:%M"): v for k, v in self.power.items()}

return power_today

0 comments on commit 554569a

Please sign in to comment.