The missing power dps was causing the swtiches to raise errors during state_attribute creation, leading them to simply not work at all. Added tests for this.
@@ -39,8 +39,8 @@ 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.")
+ if self._switch_dps is None:
+ raise AttributeError("A switch device must have a switch.")
@property
def should_poll(self):
@@ -387,5 +387,8 @@ class TestEanonsHumidifier(IsolatedAsyncioTestCase):
):
await self.switch.async_toggle()
+ def test_switch_returns_none_for_power(self):
+ self.assertIsNone(self.switch.current_power_w)
+
def test_switch_state_attributes_set(self):
self.assertEqual(self.switch.device_state_attributes, {})
@@ -371,5 +371,8 @@ class TestPulineM100Heater(IsolatedAsyncioTestCase):