-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolar_inverter_recent_production.py
More file actions
48 lines (35 loc) · 1.09 KB
/
solar_inverter_recent_production.py
File metadata and controls
48 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import datetime
from typing import Any, Dict, Type, TypeVar
from attrs import define as _attrs_define
from dateutil.parser import isoparse
T = TypeVar("T", bound="SolarInverterRecentProduction")
@_attrs_define
class SolarInverterRecentProduction:
"""
Attributes:
kwh (float): Recent production value in kWh
start (datetime.datetime): The start date of the recent production period in ISO-8601 format
"""
kwh: float
start: datetime.datetime
def to_dict(self) -> Dict[str, Any]:
kwh = self.kwh
start = self.start.isoformat()
field_dict: Dict[str, Any] = {}
field_dict.update(
{
"kwh": kwh,
"start": start,
}
)
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
kwh = d.pop("kwh")
start = isoparse(d.pop("start"))
solar_inverter_recent_production = cls(
kwh=kwh,
start=start,
)
return solar_inverter_recent_production