Skip to content

Commit

Permalink
Re-Fix charging condition (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
vwt12eh8 authored Aug 1, 2022
1 parent adb7a6f commit e7585fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/ecoflow/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ def __updated(self, data: dict[str, Any]):

def _on_updated(self, data: dict[str, Any]):
if "in_power" in data:
self._in_power = bool(data["in_power"])
self._in_power = data["in_power"]
if "out_power" in data:
self._out_power = bool(data["out_power"])
self._out_power = data["out_power"]
if "battery_level" in data:
self._battery_level = data["battery_level"]
if "battery_level_max" in data:
self._battery_level_max = data["battery_level_max"]

if not self._in_power:
self._attr_is_on = False
elif self._battery_level is not None and self._battery_level_max is not None and self._battery_level_max < self._battery_level:
elif (self._battery_level is not None) and (self._battery_level_max is not None) and (self._battery_level_max < self._battery_level):
self._attr_is_on = False
elif self._in_power is not None and self._out_power is not None and self._in_power <= self._out_power:
elif (self._in_power is not None) and (self._out_power is not None) and (self._in_power <= self._out_power):
self._attr_is_on = False
else:
self._attr_is_on = True
Expand Down

0 comments on commit e7585fd

Please # to comment.