To my understanding all the input_boolean, input_datetime, input_number, input_select and input_text are able to survive HA restart, as HA save the states into core.restore_state file every 15 minutes and just before restart or shutdown.
I noticed mine doesn’t restore the state after reboot, I found out it do the every 15 min save, but not restart/shutdown.
so I create a bunch of test entity without initial value and a test tab on lovelace for me input all the value. At the same time open up two terminal windows to monitor the /.storage folder and the content of the core.restore_state file. I can see the file update the value every 15 minutes. but whenever I restart HA, it’s a hit or miss situation, sometime it update, sometime it doesn’t. It’s just so random I can’t figure out what may be causing it.
Yes, I did.
I assume a lot of people uses input_* component, but I didn’t see anyone mention they having problem. Am I the only one ? Does yours causing any problem with HA restart ?
The file core.restore_state only get update every 15 minutes and just before restart or shutdown.
If I left HA running, I can see the file get update every 15 minutes perfectly. and a pair of log always show up
DEBUG (MainThread) [homeassistant.helpers.restore_state] Dumping states
DEBUG (SyncWorker_0) [homeassistant.helpers.storage] Writing data for core.restore_state
but when I do a system restart, almost 9 out of 10 times I’ll only have the Dumping States line only, and won’t see the Writing data for core.restore_state
I believe I found the root cause of the problem I’m encountering.
A Visual Studio Code browser tab causing the system not to do the last save states just before HA restart.
I always have at least 2 tab open, 1 tab is the HA overview, and 1 tab is always the VScode and I pretty much always have the VScode active and never close or switch that tab away from VScode. As such. the last state save was not perform upon HA restart. If I close that VScode tab, everything work as expected. core.restore_state get updated, thus input_* state got load back upon startup.
I suppose most people use 1 tab to switch between Configuration, VScode, Overview…etc thus this problem rarely show up.
I had gone as far as creating a brand new instance of Hassio from scratch and only install Visual Studio Code Add-on. Using the default plain jane configuraiton.yaml and add input_text entity in there to perform my test. I believe by doing so I should have ruled out all configuration, integration and add-on influences.
if anyone stumble upon this thread and having trouble with entity states suppose to survive restart but didn’t AND you’re using Visual Studio Code v2.4.0 try closing the VScode tab before restart and see if it helps. this happen to me on HA 0.111.7 to 0.112.4 to 0,113.0, 0,113.1, 0.113.2 and 0.113.3
Me either. Majority of my input_* have initial value and I accepted the fact from the old days that if one should restart HA, state won’t be saved. So I never pay attention to this.
Not until I found the code that made timer resume upon restart, which require input_text to get it working. I want it so badly, and it doesn’t work on my HA, and found no post regarding broken input_* so I knew it’s either my own HA installation problem, or it’s some super duper rare case and I’m on my own to troubleshoot. I kept doubting my finding until I start a install-from-scratch-bare-HA installation earlier today, which I can’t blame anything else anymore because this is rock bottom bare installation.
I’m still open to suggestion because I love using VScode. Closing the tab + restart + Re-opening Vscode will eventually become annoying.
Spent sometime on testing this, setup a brand new instance of HassOS using official vmdk file, no integration setup, only added VScode addon, the configuration,yaml only have 3 lines.
default_config:
input_text:
test_saving:
If I have the VScode open on a browser tab, the input_text won’t be save upon restart.
If I close VScode tab, the input_text will save and survive reboot.
I opened an issue for this back on 6/15. 2 months and only a few replies from others having the same issue. I’m not using the vscode addon. I can see the core.restore_state file update with the correct value then a few seconds later, it updates again with unknown. I’m temporarily working about it by storing the values in mqtt with retain = true. Not the best way to do things but when I’m restarting ha multiple times while testing and setting up new things, I was losing state values constantly.
It maybe ingress related as Paul Sinclair pointed out here. If I don’t open any extra HA tab, just use one browser tab to edit, view and restart, everything works fine and that’s my work around now, the reboot is like 4~5 times faster. Give that a try and see if it helps.