Skip to content

Commit

Permalink
Showing 7 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions custom_components/tahoma/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -60,6 +60,12 @@ def device_class(self):

def update(self):
"""Update the state."""
exec_queue = self.controller.get_current_executions()
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])

if CORE_CONTACT_STATE in self.tahoma_device.active_states:
6 changes: 6 additions & 0 deletions custom_components/tahoma/climate.py
Original file line number Diff line number Diff line change
@@ -299,6 +299,12 @@ def update_temp(self, state=None):

def update(self):
"""Update the state."""
exec_queue = self.controller.get_current_executions()
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])
self.update_temp(None)
if self._widget == W_ST:
12 changes: 6 additions & 6 deletions custom_components/tahoma/cover.py
Original file line number Diff line number Diff line change
@@ -89,13 +89,13 @@ def __init__(self, tahoma_device, controller):

def update(self):
"""Update method."""
self.controller.get_states([self.tahoma_device])

exec_queue = self.controller.get_current_executions()
for exec_id in self._exec_queue:
if exec_id in exec_queue:
self.schedule_update_ha_state(True)
return
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])

# Set current position.
# Home Assistant: 0 is closed, 100 is fully open.
9 changes: 6 additions & 3 deletions custom_components/tahoma/light.py
Original file line number Diff line number Diff line change
@@ -130,10 +130,13 @@ def effect(self) -> str:
return self._effect

def update(self):
"""Fetch new state data for this light.
"""Fetch new state data for this light."""

This is the only method that should fetch new data for Home Assistant.
"""
exec_queue = self.controller.get_current_executions()
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])

6 changes: 6 additions & 0 deletions custom_components/tahoma/lock.py
Original file line number Diff line number Diff line change
@@ -42,6 +42,12 @@ def __init__(self, tahoma_device, controller):

def update(self):
"""Update method."""
exec_queue = self.controller.get_current_executions()
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])
self._battery_level = self.tahoma_device.active_states["core:BatteryState"]
self._name = self.tahoma_device.active_states["core:NameState"]
6 changes: 6 additions & 0 deletions custom_components/tahoma/sensor.py
Original file line number Diff line number Diff line change
@@ -105,6 +105,12 @@ def device_class(self) -> Optional[str]:

def update(self):
"""Update the state."""
exec_queue = self.controller.get_current_executions()
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])

if CORE_LUMINANCE_STATE in self.tahoma_device.active_states:
6 changes: 6 additions & 0 deletions custom_components/tahoma/switch.py
Original file line number Diff line number Diff line change
@@ -41,6 +41,12 @@ def update(self):
self._skip_update = False
return

exec_queue = self.controller.get_current_executions()
self._exec_queue = [e for e in self._exec_queue if e in exec_queue]
if self._exec_queue:
self.schedule_update_ha_state(True)
return

self.controller.get_states([self.tahoma_device])

_LOGGER.debug("Update %s, state: %s", self._name, self._state)

0 comments on commit c98c526

Please sign in to comment.