mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Bugfix group reload (#5292)
* Bugfix group / hit update * try to fix round 2 * Convert it to coro * Don't check statemachine, check unsub listener.
This commit is contained in:
parent
f7a1d63d52
commit
baa8e53e66
@ -359,14 +359,16 @@ class Group(Entity):
|
|||||||
"""Start tracking members."""
|
"""Start tracking members."""
|
||||||
run_callback_threadsafe(self.hass.loop, self.async_start).result()
|
run_callback_threadsafe(self.hass.loop, self.async_start).result()
|
||||||
|
|
||||||
|
@callback
|
||||||
def async_start(self):
|
def async_start(self):
|
||||||
"""Start tracking members.
|
"""Start tracking members.
|
||||||
|
|
||||||
This method must be run in the event loop.
|
This method must be run in the event loop.
|
||||||
"""
|
"""
|
||||||
self._async_unsub_state_changed = async_track_state_change(
|
if self._async_unsub_state_changed is None:
|
||||||
self.hass, self.tracking, self._state_changed_listener
|
self._async_unsub_state_changed = async_track_state_change(
|
||||||
)
|
self.hass, self.tracking, self._async_state_changed_listener
|
||||||
|
)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
"""Unregister the group from Home Assistant."""
|
"""Unregister the group from Home Assistant."""
|
||||||
@ -392,20 +394,24 @@ class Group(Entity):
|
|||||||
|
|
||||||
This method must be run in the event loop.
|
This method must be run in the event loop.
|
||||||
"""
|
"""
|
||||||
yield from super().async_remove()
|
|
||||||
|
|
||||||
if self._async_unsub_state_changed:
|
if self._async_unsub_state_changed:
|
||||||
self._async_unsub_state_changed()
|
self._async_unsub_state_changed()
|
||||||
self._async_unsub_state_changed = None
|
self._async_unsub_state_changed = None
|
||||||
|
|
||||||
@callback
|
yield from super().async_remove()
|
||||||
def _state_changed_listener(self, entity_id, old_state, new_state):
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def _async_state_changed_listener(self, entity_id, old_state, new_state):
|
||||||
"""Respond to a member state changing.
|
"""Respond to a member state changing.
|
||||||
|
|
||||||
This method must be run in the event loop.
|
This method must be run in the event loop.
|
||||||
"""
|
"""
|
||||||
|
# removed
|
||||||
|
if self._async_unsub_state_changed is None:
|
||||||
|
return
|
||||||
|
|
||||||
self._async_update_group_state(new_state)
|
self._async_update_group_state(new_state)
|
||||||
self.hass.async_add_job(self.async_update_ha_state())
|
yield from self.async_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _tracking_states(self):
|
def _tracking_states(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user