Restore states on HA restart

Hello,
I have configured HA to use recorder and history component as required to restore states on restart. I have multiple mqtt dht11 sensors and they report only on temperature change. On restart states are lost. Also I have inputs(boolean, number) and automations that don’t restore their states on restart. Am I missing something or this is not implemented? Here is the configuration

recorder:
  purge_interval: 1
  purge_keep_days: 1
history:
  include:
    domains:
      - automation
      - binary_sensor
      - fan
      - input_boolean
      - input_number
      - light
      - sensor
      - switch

maybe look at mqtt retain flag

HA is using MQTT message to set state.
No MQTT message may cause reset sensor at start
retain should keep message so it will retrieve last state at start

if using HA MQTT server, not sure how this affect that.
Someone else may know how HA mqtt server set state at restart

recorder:, history:, and logbook: only record state history. they do not restore current states on HA load. MQTT has the retain option but I haven’t used it. There are times I would like for states to be restored, but it’s a minor inconvenience. I work in industrial controls and it’s never a good idea to have equipment auto start or return to their previous state on system start or reboot. So maybe that’s why it doesn’t bother me as much.

Thanks. Today I will update my sensors to use retain flag, but what about inputs and automations

I have the same problem (I’d like to keep the state of automations (active/not active) between restarts). I tried to revive an old thread that seemed to be spot-on on this feature, let’s see if someone helps:

1 Like

I just started using the persistence package from @dale3h to accomplish this for my input_booleans.

3 Likes

Hi. Sorry for reviving an old topic.
Trying to get dale3h persistance.yaml to work but i’m failing.
Is there any prerequisites to make it work.
Currently for example im not running MQTT, but i can see it mentioned in the automations. Is that required? Anything more?

Yes, MQTT is required.

I stumble upon a bug with the “package”.
It seems that some entities, (rfxtrx), get stuck in a loop.
I turn them off, and then the rfxtrx goes bananas and turn it on-off-on-off…
Only way to fix it is to remove the package from loading.
Anyone else experience the same behavior?

Rfxtrx entities have an attribute named state, which breaks mqtt_statestream (https://github.com/home-assistant/home-assistant/issues/11225) because it can’t differentiate between the device state and the state attribute. Perhaps this is another victim of that poorly named attribute.