mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 22:34:04 +02:00
* Fix for HA <= 2024.3, closes #973 * Link
This commit is contained in:
parent
edf0427131
commit
1a2cd7399d
2 changed files with 8 additions and 2 deletions
|
|
@ -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"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ from homeassistant.const import (
|
|||
STATE_OFF,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.const import __version__ as ha_version
|
||||
from homeassistant.core import (
|
||||
CALLBACK_TYPE,
|
||||
Context,
|
||||
|
|
@ -949,10 +950,15 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue