Remove deprecated 'run_immediately' (#991)

This commit is contained in:
Frosh 2024-05-12 20:32:46 +02:00 committed by GitHub
commit b746e5f19c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,7 +60,6 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
)
from homeassistant.const import __version__ as ha_version
from homeassistant.core import (
CALLBACK_TYPE,
Context,
@ -950,15 +949,9 @@ 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,
**kw,
)
last_state: State | None = await self.async_get_last_state()
is_new_entry = last_state is None # newly added to HA
@ -1665,12 +1658,10 @@ class AdaptiveLightingManager:
self.hass.bus.async_listen(
EVENT_CALL_SERVICE,
self.turn_on_off_event_listener,
run_immediately=False,
),
self.hass.bus.async_listen(
EVENT_STATE_CHANGED,
self.state_changed_event_listener,
run_immediately=False,
),
]