Explorar o código

Fix is_on detection

Was following lock example of state method, but switch is not using state to mirror an attribute.
Jason Rumney %!s(int64=5) %!d(string=hai) anos
pai
achega
0f6ec31455
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      custom_components/tuya_local/kogan_socket/switch.py

+ 3 - 2
custom_components/tuya_local/kogan_socket/switch.py

@@ -59,10 +59,11 @@ class KoganSocketSwitch(SwitchEntity):
     @property
     def is_on(self):
         """Return the whether the switch is on."""
-        if self.is_switched_on is None:
+        is_switched_on = self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_SWITCH])
+        if is_switched_on is None:
             return STATE_UNAVAILABLE
         else:
-            return self.is_switched_on
+            return is_switched_on
 
     @property
     def current_power_w(self):