|
6 | 6 |
|
7 | 7 | from abc import ABC, abstractmethod |
8 | 8 | from dataclasses import dataclass, field |
9 | | -from datetime import datetime |
| 9 | +from datetime import datetime, timezone |
10 | 10 | from typing import List, Optional, Tuple |
11 | 11 |
|
12 | 12 | import frequenz.api.microgrid.battery_pb2 as battery_pb |
13 | 13 | import frequenz.api.microgrid.inverter_pb2 as inverter_pb |
14 | 14 | import frequenz.api.microgrid.microgrid_pb2 as microgrid_pb |
15 | | -import pytz |
16 | 15 |
|
17 | 16 | from ._component_states import EVChargerCableState, EVChargerComponentState |
18 | 17 |
|
@@ -93,7 +92,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> MeterData: |
93 | 92 | """ |
94 | 93 | meter_data = cls( |
95 | 94 | component_id=raw.id, |
96 | | - timestamp=raw.ts.ToDatetime(tzinfo=pytz.UTC), |
| 95 | + timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc), |
97 | 96 | active_power=raw.meter.data.ac.power_active.value, |
98 | 97 | current_per_phase=( |
99 | 98 | raw.meter.data.ac.phase_1.current.value, |
@@ -166,7 +165,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> BatteryData: |
166 | 165 | """ |
167 | 166 | battery_data = cls( |
168 | 167 | component_id=raw.id, |
169 | | - timestamp=raw.ts.ToDatetime(tzinfo=pytz.UTC), |
| 168 | + timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc), |
170 | 169 | soc=raw.battery.data.soc.avg, |
171 | 170 | soc_lower_bound=raw.battery.data.soc.system_bounds.lower, |
172 | 171 | soc_upper_bound=raw.battery.data.soc.system_bounds.upper, |
@@ -221,7 +220,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> InverterData: |
221 | 220 | """ |
222 | 221 | inverter_data = cls( |
223 | 222 | component_id=raw.id, |
224 | | - timestamp=raw.ts.ToDatetime(tzinfo=pytz.UTC), |
| 223 | + timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc), |
225 | 224 | active_power=raw.inverter.data.ac.power_active.value, |
226 | 225 | active_power_lower_bound=raw.inverter.data.ac.power_active.system_bounds.lower, |
227 | 226 | active_power_upper_bound=raw.inverter.data.ac.power_active.system_bounds.upper, |
@@ -272,7 +271,7 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> EVChargerData: |
272 | 271 | """ |
273 | 272 | ev_charger_data = cls( |
274 | 273 | component_id=raw.id, |
275 | | - timestamp=raw.ts.ToDatetime(tzinfo=pytz.UTC), |
| 274 | + timestamp=raw.ts.ToDatetime(tzinfo=timezone.utc), |
276 | 275 | active_power=raw.ev_charger.data.ac.power_active.value, |
277 | 276 | current_per_phase=( |
278 | 277 | raw.ev_charger.data.ac.phase_1.current.value, |
|
0 commit comments