4
0
Эх сурвалжийг харах

Ensure _power_dps and _switch_dps are created, even if they are None.

Jason Rumney 5 жил өмнө
parent
commit
fac79e8c33

+ 5 - 0
custom_components/tuya_local/generic/switch.py

@@ -27,6 +27,8 @@ class TuyaLocalSwitch(SwitchEntity):
         """
         self._device = device
         self._config = config
+        self._switch_dps = None
+        self._power_dps = None
         self._attr_dps = []
         for d in config.dps():
             if d.name == "switch":
@@ -37,6 +39,9 @@ class TuyaLocalSwitch(SwitchEntity):
                 if not d.hidden:
                     self._attr_dps.append(d)
 
+    if self._switch_dps is None:
+        raise AttributeError("A switch device must have a switch.")
+
     @property
     def should_poll(self):
         """Return the polling state."""