mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Move scene and button restore to internal hook (#65696)
This commit is contained in:
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…
x
Reference in New Issue
Block a user