-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallbox_system_state.py
38 lines (27 loc) · 1.21 KB
/
wallbox_system_state.py
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
import datetime
from pv_modbus_wallbox import WBDef
class WBSystemState:
def __init__(self, slave_id):
self.slave_id = slave_id
charge_state: WBDef = 0
pcb_temperature = 0
standby_requested: WBDef = WBDef.DISABLE_STANDBY
standby_active: WBDef = WBDef.DISABLE_STANDBY
max_current_active = 0
last_time_max_current_was_set: datetime.datetime = 0
actual_current_active = 0
max_failsafe_current_active = 0
pv_charge_active: bool = False
grid_charge_active: bool = False
# datetime when the WB started charging
last_charge_activation: datetime.datetime = 0
# datetime when the WB stopped charging
last_charge_deactivation: datetime.datetime = 0
def __eq__(self, other): # only comparing what is relevant to be saved. Only a bit ugly :)
if not isinstance(other, WBSystemState):
return NotImplemented
return self.charge_state == other.charge_state \
and self.pv_charge_active == other.pv_charge_active \
and self.grid_charge_active == other.grid_charge_active \
and self.max_current_active == other.max_current_active \
and self.actual_current_active == other.actual_current_active