mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
ESPHome Fix intermediary state published (#27638)
Fixes https://github.com/esphome/issues/issues/426
This commit is contained in:
parent
79b391c673
commit
a79a9809f4
@ -479,7 +479,9 @@ class EsphomeEntity(Entity):
|
|||||||
}
|
}
|
||||||
self._remove_callbacks.append(
|
self._remove_callbacks.append(
|
||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
self.hass, DISPATCHER_UPDATE_ENTITY.format(**kwargs), self._on_update
|
self.hass,
|
||||||
|
DISPATCHER_UPDATE_ENTITY.format(**kwargs),
|
||||||
|
self._on_state_update,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -493,14 +495,23 @@ class EsphomeEntity(Entity):
|
|||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
self.hass,
|
self.hass,
|
||||||
DISPATCHER_ON_DEVICE_UPDATE.format(**kwargs),
|
DISPATCHER_ON_DEVICE_UPDATE.format(**kwargs),
|
||||||
self.async_schedule_update_ha_state,
|
self._on_device_update,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def _on_update(self) -> None:
|
async def _on_state_update(self) -> None:
|
||||||
"""Update the entity state when state or static info changed."""
|
"""Update the entity state when state or static info changed."""
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
|
async def _on_device_update(self) -> None:
|
||||||
|
"""Update the entity state when device info has changed."""
|
||||||
|
if self._entry_data.available:
|
||||||
|
# Don't update the HA state yet when the device comes online.
|
||||||
|
# Only update the HA state when the full state arrives
|
||||||
|
# through the next entity state packet.
|
||||||
|
return
|
||||||
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
async def async_will_remove_from_hass(self) -> None:
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
"""Unregister callbacks."""
|
"""Unregister callbacks."""
|
||||||
for remove_callback in self._remove_callbacks:
|
for remove_callback in self._remove_callbacks:
|
||||||
|
@ -47,9 +47,9 @@ class EsphomeCamera(Camera, EsphomeEntity):
|
|||||||
def _state(self) -> Optional[CameraState]:
|
def _state(self) -> Optional[CameraState]:
|
||||||
return super()._state
|
return super()._state
|
||||||
|
|
||||||
async def _on_update(self) -> None:
|
async def _on_state_update(self) -> None:
|
||||||
"""Notify listeners of new image when update arrives."""
|
"""Notify listeners of new image when update arrives."""
|
||||||
await super()._on_update()
|
await super()._on_state_update()
|
||||||
async with self._image_cond:
|
async with self._image_cond:
|
||||||
self._image_cond.notify_all()
|
self._image_cond.notify_all()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user