-
Notifications
You must be signed in to change notification settings - Fork 58
-
Hi all,
I have pyscript running on my HA system with a python script that is meant to be called by an automation under certain conditions.
During HA startup, the conditions for the automation are true pretty much as soon as the helper state and automations are loaded, and this allows the automation to call the python script before pyscript has finished initializing - the name of my service isn't found.
Is there some sort of state available from the pyscript object that I can use as a condition in my automation to keep it from trying to call the python script until after pyscript is done initializing?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 4 comments 1 reply
-
pyscript
initializes itself, loads all the user scripts, and runs all @startup
triggers when the EVENT_HOMEASSISTANT_STARTED
occurs. That's to make sure all other components are already loaded.
Could you do something like this:
@time_trigger("startup") def pyscript_startup(): pyscript.started = 1
Could you then qualify your automation on pyscript.started == '1' (although it won't be defined until it's set)?
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
Could you try this to reset the variable at shutdown?
@time_trigger("shutdown") def pyscript_shutdown(): pyscript.started = 0
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.