-
Notifications
You must be signed in to change notification settings - Fork 58
State variables (entity_id) after reboot #597
-
I just a quick question:
When I set the state with
state.set("sensor.test1", new_attributes={}, value=event_date)
I cannot access it after restart, but if I set it again new or the same value I can see the history of it
Is there any way to get the last states back after start up without running the main script
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 1 reply
-
I have never tried it, but could it be this? https://hacs-pyscript.readthedocs.io/en/latest/reference.html?highlight=persist#persistent-state
Beta Was this translation helpful? Give feedback.
All reactions
-
state.persist('pyscript.current_shower_fan', default_value='fan.shower') @time_trigger('once(10:30:00)') def current_shower_fan_switcher(trigger_type=None, var_name=None, value=None, old_value=None, context=None, **kwargs): log.debug(f"changing pyscript.current_shower_fan from {pyscript.current_shower_fan} to fan.shower_top") pyscript.current_shower_fan = 'fan.shower_top' # then current_shower_fan_state = state.get(f"{pyscript.current_shower_fan}")
Beta Was this translation helpful? Give feedback.
All reactions
-
This persists sensors in the pyscript domain. Is there a way to make other sensors persist? Or is it a case of making sure your script re-initialises those sensors every time it starts up?
Beta Was this translation helpful? Give feedback.