Move scene and button restore to internal hook (#65696)
parent
8021b05448
commit
2a8797ae3f
|
@ -113,8 +113,9 @@ class ButtonEntity(RestoreEntity):
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
await self.async_press()
|
await self.async_press()
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_internal_added_to_hass(self) -> None:
|
||||||
"""Call when the button is added to hass."""
|
"""Call when the button is added to hass."""
|
||||||
|
await super().async_internal_added_to_hass()
|
||||||
state = await self.async_get_last_state()
|
state = await self.async_get_last_state()
|
||||||
if state is not None and state.state is not None:
|
if state is not None and state.state is not None:
|
||||||
self.__last_pressed = dt_util.parse_datetime(state.state)
|
self.__last_pressed = dt_util.parse_datetime(state.state)
|
||||||
|
|
|
@ -113,8 +113,9 @@ class Scene(RestoreEntity):
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
await self.async_activate(**kwargs)
|
await self.async_activate(**kwargs)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_internal_added_to_hass(self) -> None:
|
||||||
"""Call when the button is added to hass."""
|
"""Call when the scene is added to hass."""
|
||||||
|
await super().async_internal_added_to_hass()
|
||||||
state = await self.async_get_last_state()
|
state = await self.async_get_last_state()
|
||||||
if state is not None and state.state is not None:
|
if state is not None and state.state is not None:
|
||||||
self.__last_activated = state.state
|
self.__last_activated = state.state
|
||||||
|
|
Loading…
Reference in New Issue