Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions custom_components/pyscript/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,8 @@ async def state_changed(event: HAEvent) -> None:
await State.update(new_vars, func_args)

async def hass_started(event: HAEvent) -> None:
_LOGGER.debug("adding state changed listener and starting global contexts")
_LOGGER.debug("starting global contexts")
await State.get_service_params()
hass.data[DOMAIN][UNSUB_LISTENERS].append(hass.bus.async_listen(EVENT_STATE_CHANGED, state_changed))
start_global_contexts()

async def hass_stop(event: HAEvent) -> None:
Expand All @@ -367,6 +366,8 @@ async def hass_stop(event: HAEvent) -> None:
await Function.reaper_stop()

# Store callbacks to event listeners so we can unsubscribe on unload
_LOGGER.debug("adding state_changed listener")
hass.data[DOMAIN][UNSUB_LISTENERS].append(hass.bus.async_listen(EVENT_STATE_CHANGED, state_changed))
hass.data[DOMAIN][UNSUB_LISTENERS].append(
hass.bus.async_listen(EVENT_HOMEASSISTANT_STARTED, hass_started)
)
Expand Down