diff --git a/custom_components/adaptive_lighting/manifest.json b/custom_components/adaptive_lighting/manifest.json index 96cec4ac..2ec04e27 100644 --- a/custom_components/adaptive_lighting/manifest.json +++ b/custom_components/adaptive_lighting/manifest.json @@ -8,5 +8,5 @@ "iot_class": "calculated", "issue_tracker": "https://github.com/basnijholt/adaptive-lighting/issues", "requirements": ["ulid-transform"], - "version": "1.21.0" + "version": "1.21.1" } diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 9408d90b..2b23c71c 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -60,6 +60,7 @@ STATE_OFF, STATE_ON, ) +from homeassistant.const import __version__ as ha_version from homeassistant.core import ( CALLBACK_TYPE, Context, @@ -949,10 +950,15 @@ async def async_added_to_hass(self) -> None: if self.hass.is_running: await self._setup_listeners() else: + kw = {} + year, month = (int(x) for x in ha_version.split(".")[:2]) + if (year, month) >= (2024, 4): + # Added in https://github.com/home-assistant/core/pull/113020 + kw["run_immediately"] = False self.hass.bus.async_listen_once( EVENT_HOMEASSISTANT_STARTED, self._setup_listeners, - run_immediately=False, + **kw, ) last_state: State | None = await self.async_get_last_state() is_new_entry = last_state is None # newly added to HA