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:
parent
5d8a465c18
commit
41aaeb715a
18 changed files with 80 additions and 56 deletions
|
@ -137,7 +137,7 @@ class FluxSwitch(SwitchDevice):
|
|||
self._state = True
|
||||
self.unsub_tracker = track_utc_time_change(self.hass, self.flux_update,
|
||||
second=[0, 30])
|
||||
self.update_ha_state()
|
||||
self.shedule_update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn off flux."""
|
||||
|
@ -146,7 +146,7 @@ class FluxSwitch(SwitchDevice):
|
|||
self.unsub_tracker = None
|
||||
|
||||
self._state = False
|
||||
self.update_ha_state()
|
||||
self.shedule_update_ha_state()
|
||||
|
||||
def flux_update(self, now=None):
|
||||
"""Update all the lights using flux."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue