You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a module that contains some boilerplate code for state_triggers that I wan to call from some other files.
If I define the factory in a module, the state seems to be set by the looks of the logs but it is never triggered. now if I define the same factory in the file I am calling then this is working as expected.
On my example I created these two files:
test_trigger.py inside the modules folder and test_dev.py in the pyscript folder
Possible race condition related to my issue #647 ? You can try instantiating f1 and f2 within the below function so they will be made on boot and after everything else is loaded, or for testing try tying them to a button through state trigger. It's the bare calls in the body of the file that may be the issue here.
@time_triggerdefrun_on_startup_or_reload():
"""This function runs automatically once on startup or reload"""pass
@time_triggerdefrun_on_startup_or_reload():
log.debug("Running on startup or reload")
"""This function runs automatically once on startup or reload"""f1=on_change_from_within("light.office_wall_leds")
f2=trigger_factory_test("light.office_wall_leds")
pass
then it makes even the one in the test_dev.py that used to work to fail
The file is being correctly loaded as I added another one
I am trying to write a module that contains some boilerplate code for state_triggers that I wan to call from some other files.
If I define the factory in a module, the state seems to be set by the looks of the logs but it is never triggered. now if I define the same factory in the file I am calling then this is working as expected.
On my example I created these two files:
test_trigger.py
inside the modules folder andtest_dev.py
in the pyscript foldercontent of
test_trigger.py
and the test_dev.py
when the light changes state I see the change on f1 but not from f2, even if I commented out the f1
Do I need to use apps for this?
The text was updated successfully, but these errors were encountered: