Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 904b60a

Browse files
author
Hagen Fritsch
committed
Do not defer listening to state_changed events until HA has started. Fixes #750
1 parent 46809fa commit 904b60a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎custom_components/pyscript/__init__.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ async def state_changed(event: HAEvent) -> None:
349349
await State.update(new_vars, func_args)
350350

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

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

369368
# Store callbacks to event listeners so we can unsubscribe on unload
369+
_LOGGER.debug("adding state_changed listener")
370+
hass.data[DOMAIN][UNSUB_LISTENERS].append(hass.bus.async_listen(EVENT_STATE_CHANGED, state_changed))
370371
hass.data[DOMAIN][UNSUB_LISTENERS].append(
371372
hass.bus.async_listen(EVENT_HOMEASSISTANT_STARTED, hass_started)
372373
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /