Home Assistant input entity states not the same after a restart

Tags: #<Tag:0x00007f73b4908ce0>

Hello everyone,

Im looking for some help with a issue I have with my Home Assistant installation I’ve spent quite a bit of time searching both here and on the internet in general and haven’t been able to find anything obviously close hence my reaching out in this post.

The problem I have is simple. Initially Home Assistant is running fine. All my automation’s work as expected and everything is great. Then after a few days I start to run into a problem with my Input Booleans/DateTime fields.

Basically they don’t remain in their last known state when I reboot Home Assistant (Which I have automated to happen daily) On reboot they revert back to a previous state. I can change them again but on the next reboot they revert back again. For example if I turn and input boolean from off to on, reboot HA, that input boolean is back to off.

My install is on a Raspberry Pi 4 with the 32bit HA image installed. I get this problem whether I use the default Database or if I use MariaDB. Initially I can change my Inputs and they remember their states at restart but after a while I end up with the issue reported above.

If I delete the database and start again everything is fine but sooner or later the problem returns and my Input Booleans do not restart on their previous values.

I have managed to delay this happening by setting purge_keep_days to 1 in Recorder and reducing the number of items Included in Recorder to the bear minimum

When using MariaDB and phpMyAdmin I can see the value of those inputs being saved in the database when I change them (ie turn one of them to off). Looking again at the same entry in phpMyAdmin I can also see them being updated back to the wrong value after HA has restarted

Something somewhere is causing my HA to remember the wrong value after a restart and I’m looking for any advice people may have to help me resolve this

Many thanks

Input_booleans don’t retain their value over a reboot. You can set an initial value for them to take after a restart, or they will default to false. Docs here.

Similarly with input_datetime, you can set a default value, or it will default to 1970-01-01 00:00 | 00:00 | 1970-01-01. Docs here

Input_number does retain the value at shutdown, unless you specify an initial value. Docs here

I suppose you clould use input_number instead of boolean and assign a value of 1 or 0.

1 Like

Hi Stiltjack

Thanks for getting back to me. I hear what you are saying but I dont believe you are correct nor does what you have said match my experience.

The link to the input_booleans docs clearly states that " If you set a valid value for initial this integration will start with state set to that value. Otherwise, it will restore the state it had prior to Home Assistant stopping."

None of my booleans have an initial value set and for a while they do restart at their previous value. But sooner or later they dont as described above.

The same thing happens on my Input_Datetimes. For example I have one that I use as a start time for an automation. It was set to 09:30:00 for a long time. The other day I changed that to 10:30:00 but it reverted back to 09:30:00 after a restart.

Only by deleting my database and effectively starting again could I get it to stay at the value I set it. But past experiences has shown me that Ill be back with the same problem again soon.

You’re right, it does. I was looking at this bit:


I had the same problem a while ago and this seemed to be the issue (not helped by dodgy documentation? :thinking:).

In the end I used a spare Wireless Sensor Tag to store values outside HA. These have three sensors (temperature, humidity and movement) which can be armed or disarmed from HA - I used them to store the value of input-booleans and an automation to restore the values after a restart. A bit Heath Robinson, but it works. The tags are battery powered, so values survive power cuts. Input-boolean values also get refreshed from the tag every night by another automation, so they’ve never been left long enough to reproduce your experience.

I’ve not seen this myself, and I use many booleans (and other input_X entities).

It sounds like you’ve got a problem with the state restore process (which doesn’t use the same database as recorder).

Even if you can’t find anything useful in the log file I’d open an issue about this. It’s not at all normal, so there’s something odd going on with your setup, which likely means that others have the same problem but haven’t noticed.

The docs do seem contradictory, though. Should we expect input_x values to be retained or not?

The docs aren’t contradictory


If you set a valid value for initial this integration will start with state set to that value. Otherwise, it will restore the state it had prior to Home Assistant stopping.

I’m not sure what’s contradictory there.

If you mean the mis-reading of:

initial boolean(optional, default: false)

Then that says that the default value of that setting is false. That’s common language throughout the integration docs.

Maybe the integrations need a primer on how to read them :thinking:

Good idea! I’ll subscribe.


It not happening right now so the logs dont have anything useful regarding this issue, assuming they do when it does happen. However I will follow your advice and raise an issue to get this looked at.

Past experience shows its only a matter of time before the issue comes back…

Thanks to you and Stiltjack for for help and guidance on this

As suggested I raised this as an issue and got a few comment though no actual fix.

However I do have an update from what I have witnessed I last deleted my database back on the 23rd Sept, which seems to be the only thing I could do to resolve this issues, and started again.

Sine then its behaved perfectly. I haven’t had any problem with my Inputs being in a different state after a restart.

Im not sure if anything has changed in the latest release (I was on 0.115.6 then and an now on 0.116.4) that would affect this.

The only change I made after I deleted my database was to remove the “keep_days” and “repack” statements from the Recorder section in my Config. Now I have them in a script that runs daily.

I dont know if that has any impact on this issue but as I say I haven’t had this issue since and right now my HA database is holding the last 7 days data which is something it would never do before.