From e7585fd09ffbb5dfe3feaf66ea56f2d1ec43e4f1 Mon Sep 17 00:00:00 2001 From: vwt12eh8 <63479906+vwt12eh8@users.noreply.github.com> Date: Mon, 1 Aug 2022 19:39:38 +0900 Subject: [PATCH] Re-Fix charging condition (#24) --- custom_components/ecoflow/binary_sensor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/ecoflow/binary_sensor.py b/custom_components/ecoflow/binary_sensor.py index cbb55c4..88add82 100644 --- a/custom_components/ecoflow/binary_sensor.py +++ b/custom_components/ecoflow/binary_sensor.py @@ -72,9 +72,9 @@ 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: @@ -82,9 +82,9 @@ def _on_updated(self, data: dict[str, Any]): 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