Skip to content

Commit

Permalink
Fix for HA <= 2024.3, closes #973 (#974)
Browse files Browse the repository at this point in the history
* Fix for HA <= 2024.3, closes #973

* Link
  • Loading branch information
basnijholt authored Apr 9, 2024
1 parent edf0427 commit 1a2cd73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/adaptive_lighting/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
8 changes: 7 additions & 1 deletion custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
STATE_OFF,
STATE_ON,
)
from homeassistant.const import __version__ as ha_version
from homeassistant.core import (
CALLBACK_TYPE,
Context,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1a2cd73

Please sign in to comment.