ESPHome Fix intermediary state published (#27638)
Fixes https://github.com/esphome/issues/issues/426pull/27652/head
parent
79b391c673
commit
a79a9809f4
|
@ -479,7 +479,9 @@ class EsphomeEntity(Entity):
|
|||
}
|
||||
self._remove_callbacks.append(
|
||||
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(
|
||||
self.hass,
|
||||
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."""
|
||||
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:
|
||||
"""Unregister callbacks."""
|
||||
for remove_callback in self._remove_callbacks:
|
||||
|
|
|
@ -47,9 +47,9 @@ class EsphomeCamera(Camera, EsphomeEntity):
|
|||
def _state(self) -> Optional[CameraState]:
|
||||
return super()._state
|
||||
|
||||
async def _on_update(self) -> None:
|
||||
async def _on_state_update(self) -> None:
|
||||
"""Notify listeners of new image when update arrives."""
|
||||
await super()._on_update()
|
||||
await super()._on_state_update()
|
||||
async with self._image_cond:
|
||||
self._image_cond.notify_all()
|
||||
|
||||
|
|
Loading…
Reference in New Issue