Skip to content

Commit 1a2cd73

Browse files
authored
Fix for HA <= 2024.3, closes #973 (#974)
* Fix for HA <= 2024.3, closes #973 * Link
1 parent edf0427 commit 1a2cd73

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

custom_components/adaptive_lighting/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "calculated",
99
"issue_tracker": "https://github.com/basnijholt/adaptive-lighting/issues",
1010
"requirements": ["ulid-transform"],
11-
"version": "1.21.0"
11+
"version": "1.21.1"
1212
}

custom_components/adaptive_lighting/switch.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
STATE_OFF,
6161
STATE_ON,
6262
)
63+
from homeassistant.const import __version__ as ha_version
6364
from homeassistant.core import (
6465
CALLBACK_TYPE,
6566
Context,
@@ -949,10 +950,15 @@ async def async_added_to_hass(self) -> None:
949950
if self.hass.is_running:
950951
await self._setup_listeners()
951952
else:
953+
kw = {}
954+
year, month = (int(x) for x in ha_version.split(".")[:2])
955+
if (year, month) >= (2024, 4):
956+
# Added in https://github.com/home-assistant/core/pull/113020
957+
kw["run_immediately"] = False
952958
self.hass.bus.async_listen_once(
953959
EVENT_HOMEASSISTANT_STARTED,
954960
self._setup_listeners,
955-
run_immediately=False,
961+
**kw,
956962
)
957963
last_state: State | None = await self.async_get_last_state()
958964
is_new_entry = last_state is None # newly added to HA

0 commit comments

Comments
 (0)