Hi Folks, I am trying to store weather data of today in a state and thought of using the state.persist function available in hacs-pyscript. But once homeassistant restarts, the state is lost. I have gone through the documentation and it only mentions is to put state.persist call outside so that it is called during shutdown and startup. But I can’t seem to make it work. Some screenshots of the code below
Anyone else facing the same issue? I did see “state.persist not working” issue on github but It was resolved in 2022.3 version.
Same here, except I don’t run persist at startup/shutdown, but at the start of my script that runs every hour…
Worked for a while and then it did not when there was 2 reboot in the same hour window…
Your approach seems better though.
Can’t help you, but very interested about this.
Good to know thanks.
I’ve tested your persist functions and they seem to work well on my side.
Another option would be to create sensors with dummy values and only set them (not create them) in pyscript. It works I’ve tested it. You could also just create input_number variables in the UI and do the same.
I have the same issue. Unfortunately it is not really an option to use input_variables as I generate the names of the values I want to persist based on the script and these might change. I could create them manually but this would be a lot of manual effort. do you maybe have any other idea/workaround?