pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

Bug: module context starts before Home Assistant

Open dmamelin opened this issue 3 weeks ago • 1 comments

Module-level triggers start before Home Assistant reaches the RUNNING state

modules/module.py:

@time_trigger
def module_startup():
    log.info(f"Module hass state: {hass.state}")

test.py:

from module import module_startup
@time_trigger
def file_startup():
    log.info(f"File hass state: {hass.state}")

Log on HA startup:

[custom_components.pyscript.modules.module.module_startup] Module hass state: NOT_RUNNING
...few seconds...
[custom_components.pyscript.file.test.file_startup] File hass state: RUNNING

dmamelin avatar Dec 09 '25 13:12 dmamelin

In my setup, modules define state_trigger factories that are called from regular files. As a result, HA startup becomes inexplicably slow and unstable, with intermittent errors and other issues.

dmamelin avatar Dec 09 '25 15:12 dmamelin