From b0c1c37cd5d204b3d457d25a22a28fbcf06b6a85 Mon Sep 17 00:00:00 2001 From: Nikolay Vasilchuk Date: Mon, 1 Oct 2018 19:00:48 +0300 Subject: [PATCH] Fix long update 'load_power' and 'in_use' for Xiaomi Zegbee Plug (#16915) --- homeassistant/components/switch/xiaomi_aqara.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/homeassistant/components/switch/xiaomi_aqara.py b/homeassistant/components/switch/xiaomi_aqara.py index a29a3c74a2e..17265d5dfa2 100644 --- a/homeassistant/components/switch/xiaomi_aqara.py +++ b/homeassistant/components/switch/xiaomi_aqara.py @@ -99,6 +99,11 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchDevice): attrs.update(super().device_state_attributes) return attrs + @property + def should_poll(self): + """Return the polling state. Polling needed for zigbee plug only.""" + return self._supports_power_consumption + def turn_on(self, **kwargs): """Turn the switch on.""" if self._write_to_hub(self._sid, **{self._data_key: 'on'}): @@ -131,3 +136,8 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchDevice): return False self._state = state return True + + def update(self): + """Get data from hub.""" + _LOGGER.debug("Update data from hub: %s", self._name) + self._get_from_hub(self._sid)