Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

State variables (entity_id) after reboot #597

Unanswered
rundercaster asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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}")
You must be logged in to vote
1 reply
Comment options

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /