Convert switch to AsnycIO (#4382)

* Convert switch to AsnycIO

* Move update entity to service

* use time better for faster handling

* Change to suggestion from paulus

* Use new shedule_update_ha_state

* fix lint

* minimize executor calls
This commit is contained in:
Pascal Vizeli 2016-11-16 06:06:50 +01:00 committed by Paulus Schoutsen
parent 5d8a465c18
commit 41aaeb715a
18 changed files with 80 additions and 56 deletions

View file

@ -117,7 +117,7 @@ class MqttSwitch(SwitchDevice):
if self._optimistic:
# Optimistically assume that switch has changed state.
self._state = True
self.update_ha_state()
self.shedule_update_ha_state()
def turn_off(self, **kwargs):
"""Turn the device off."""
@ -126,4 +126,4 @@ class MqttSwitch(SwitchDevice):
if self._optimistic:
# Optimistically assume that switch has changed state.
self._state = False
self.update_ha_state()
self.shedule_update_ha_state()