File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,13 @@ def __repr__(self):
95
95
return f"{ self .in_percentage } % ({ self .absolute } )"
96
96
97
97
def __post_init__ (self ):
98
- if not self .absolute .watt_hours > battery_capacity .watt_hours :
99
- return
98
+ if self .absolute .watt_hours > battery_capacity .watt_hours :
99
+ soc_logger .log .debug (f"Capping the state of charge at the battery capacity (would be { self .absolute } )" )
100
+ self .absolute = EnergyAmount (battery_capacity .watt_hours )
100
101
101
- soc_logger .log .debug (f"Capping the state of charge at the battery capacity (would be { self .absolute } )" )
102
- self .absolute = EnergyAmount (battery_capacity .watt_hours )
102
+ if self .absolute .watt_hours < 0 :
103
+ soc_logger .log .debug (f"Capping the state of charge at 0 (would be { self .absolute } )" )
104
+ self .absolute = EnergyAmount (0 )
103
105
104
106
def __add__ (self , other : StateOfCharge ) -> StateOfCharge :
105
107
return StateOfCharge (self .absolute + other .absolute )
You can’t perform that action at this time.
0 commit comments