Răsfoiți Sursa

Check voltage when outputting voltage.

Previously we assumed that voltage and current are connected, and if one was available, the other would be too.
But it seems that is not the case, and we can get a current reading while the voltage is not reported.
Jason Rumney 5 ani în urmă
părinte
comite
11302be940
1 a modificat fișierele cu 2 adăugiri și 4 ștergeri
  1. 2 4
      custom_components/tuya_local/kogan_socket/switch.py

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

@@ -72,9 +72,7 @@ class KoganSocketSwitch(SwitchEntity):
         if pwr is None:
             return STATE_UNAVAILABLE
         else:
-            return (
-                self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_CURRENT_POWER_W]) / 10.0
-            )
+            return (pwr / 10.0)
 
     @property
     def device_state_attributes(self):
@@ -85,7 +83,7 @@ class KoganSocketSwitch(SwitchEntity):
         return {
             ATTR_CURRENT_POWER_W: self.current_power_w,
             ATTR_CURRENT_A: None if current is None else current / 1000.0,
-            ATTR_VOLTAGE_V: None if current is None else voltage / 10.0,
+            ATTR_VOLTAGE_V: None if voltage is None else voltage / 10.0,
             ATTR_TIMER: timer,
         }