state.persist #366
Unanswered
stefanuytterhoeven
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using a trigger closure.
something like
def make_waskot_auto_light(config):
#config['light_id'] contains 'light.waskot_lamp'
persist_light=f"{config['light_id'].replace('light.','pyscript.')}_lock"
state.persist(persist_light,default_value='off')
@state_trigger(....
some code...
@time_trigger('startup')
def waskot_auto_light_startup():
log.info("*** Start ")
for config in pyscript.app_config:
make_waskot_auto_light(config)
log.info(" End ***")
This way, I'm sure the state.persist is executed. I can't put the state.persist in the beginning of the source, as I don't know the variable at that moment.
And, it works...
question:
I want to you that persisted variable in other scripts. Do I need to use "state.persist" again in that source?
if not, and the ohter script is executed at startup, before this script, there's a possible the persisted variable is gone?
Is it fine to state.persist that same variable again in another script?
thx
Beta Was this translation helpful? Give feedback.
All reactions