mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 23:37:18 +00:00
Fix generic_hygrostat error at startup (#88764)
This commit is contained in:
parent
96698813ef
commit
71b5ccee23
@ -22,6 +22,8 @@ from homeassistant.const import (
|
|||||||
SERVICE_TURN_ON,
|
SERVICE_TURN_ON,
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
|
STATE_UNAVAILABLE,
|
||||||
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, callback
|
from homeassistant.core import DOMAIN as HA_DOMAIN, HomeAssistant, callback
|
||||||
from homeassistant.helpers import condition
|
from homeassistant.helpers import condition
|
||||||
@ -175,6 +177,15 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity):
|
|||||||
async def _async_startup(event):
|
async def _async_startup(event):
|
||||||
"""Init on startup."""
|
"""Init on startup."""
|
||||||
sensor_state = self.hass.states.get(self._sensor_entity_id)
|
sensor_state = self.hass.states.get(self._sensor_entity_id)
|
||||||
|
if sensor_state is None or sensor_state.state in (
|
||||||
|
STATE_UNKNOWN,
|
||||||
|
STATE_UNAVAILABLE,
|
||||||
|
):
|
||||||
|
_LOGGER.debug(
|
||||||
|
"The sensor state is %s, initialization is delayed",
|
||||||
|
sensor_state.state if sensor_state is not None else "None",
|
||||||
|
)
|
||||||
|
return
|
||||||
await self._async_sensor_changed(self._sensor_entity_id, None, sensor_state)
|
await self._async_sensor_changed(self._sensor_entity_id, None, sensor_state)
|
||||||
|
|
||||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _async_startup)
|
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _async_startup)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user