1
mirror of https://github.com/home-assistant/core synced 2024-07-27 18:58:57 +02:00

Move scene and button restore to internal hook (#65696)

This commit is contained in:
Paulus Schoutsen 2022-02-04 10:43:06 -08:00 committed by GitHub
parent 8021b05448
commit 2a8797ae3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -113,8 +113,9 @@ class ButtonEntity(RestoreEntity):
self.async_write_ha_state()
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."""
await super().async_internal_added_to_hass()
state = await self.async_get_last_state()
if state is not None and state.state is not None:
self.__last_pressed = dt_util.parse_datetime(state.state)

View File

@ -113,8 +113,9 @@ class Scene(RestoreEntity):
self.async_write_ha_state()
await self.async_activate(**kwargs)
async def async_added_to_hass(self) -> None:
"""Call when the button is added to hass."""
async def async_internal_added_to_hass(self) -> None:
"""Call when the scene is added to hass."""
await super().async_internal_added_to_hass()
state = await self.async_get_last_state()
if state is not None and state.state is not None:
self.__last_activated = state.state