Fix long update 'load_power' and 'in_use' for Xiaomi Zegbee Plug (#16915)

This commit is contained in:
Nikolay Vasilchuk 2018-10-01 19:00:48 +03:00 committed by Paulus Schoutsen
parent 4c36ffd0ef
commit b0c1c37cd5

View File

@ -99,6 +99,11 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchDevice):
attrs.update(super().device_state_attributes) attrs.update(super().device_state_attributes)
return attrs 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): def turn_on(self, **kwargs):
"""Turn the switch on.""" """Turn the switch on."""
if self._write_to_hub(self._sid, **{self._data_key: 'on'}): if self._write_to_hub(self._sid, **{self._data_key: 'on'}):
@ -131,3 +136,8 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchDevice):
return False return False
self._state = state self._state = state
return True return True
def update(self):
"""Get data from hub."""
_LOGGER.debug("Update data from hub: %s", self._name)
self._get_from_hub(self._sid)