From 2a8797ae3fa206017279b40cee06175e70a5000d Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 4 Feb 2022 10:43:06 -0800 Subject: [PATCH] Move scene and button restore to internal hook (#65696) --- homeassistant/components/button/__init__.py | 3 ++- homeassistant/components/scene/__init__.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/button/__init__.py b/homeassistant/components/button/__init__.py index 2e9a8c05163..d0e27662d41 100644 --- a/homeassistant/components/button/__init__.py +++ b/homeassistant/components/button/__init__.py @@ -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) diff --git a/homeassistant/components/scene/__init__.py b/homeassistant/components/scene/__init__.py index 774aaad0ee4..846c0fbc7c6 100644 --- a/homeassistant/components/scene/__init__.py +++ b/homeassistant/components/scene/__init__.py @@ -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