Преглед изворни кода

Fix is_on detection

Was following lock example of state method, but switch is not using state to mirror an attribute.
Jason Rumney пре 5 година
родитељ
комит
0f6ec31455
1 измењених фајлова са 3 додато и 2 уклоњено
  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):