Skip to content

Commit c726288

Browse files
committed
Add missing comparison methods for energy classes
1 parent a6fd529 commit c726288

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source/energy_classes.py

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def __mul__(self, other: float) -> EnergyAmount:
2626
def __lt__(self, other: EnergyAmount) -> bool:
2727
return self.watt_hours < other.watt_hours
2828

29+
def __le__(self, other: EnergyAmount) -> bool:
30+
return self.watt_hours <= other.watt_hours
31+
2932
def __gt__(self, other: EnergyAmount) -> bool:
3033
return self.watt_hours > other.watt_hours
3134

@@ -72,9 +75,15 @@ def __repr__(self):
7275
def __lt__(self, other: EnergyRate) -> bool:
7376
return self.rate < other.rate
7477

78+
def __le__(self, other: EnergyRate) -> bool:
79+
return self.rate <= other.rate
80+
7581
def __gt__(self, other: EnergyRate) -> bool:
7682
return self.rate > other.rate
7783

84+
def __ge__(self, other: EnergyRate) -> bool:
85+
return self.rate >= other.rate
86+
7887

7988
soc_logger = LoggerMixin("StateOfCharge")
8089
battery_capacity = EnergyAmount(int(EnvironmentVariableGetter.get("INVERTER_BATTERY_CAPACITY")))
@@ -105,6 +114,9 @@ def __sub__(self, other: StateOfCharge) -> StateOfCharge:
105114
def __lt__(self, other: StateOfCharge) -> bool:
106115
return self.absolute < other.absolute
107116

117+
def __le__(self, other: StateOfCharge) -> bool:
118+
return self.absolute <= other.absolute
119+
108120
def __gt__(self, other: StateOfCharge) -> bool:
109121
return self.absolute > other.absolute
110122

0 commit comments

Comments
 (0)