Restore on Startup

Hi all,

I’m moving from a OpenHAB2 installation to Home Assistant.
My setup is using project to get values via MQTT around my home. The chain looks like this:

MySensor nodes -> Mysensor Gateway (MQTT client) -> Mosquitto (MQTT server) <- MQTT client from Home Assistant

On my previous setup I’ve an option to restore on startup values. This was useful for some cases. In example:
My MySensors device sends on boot it’s name and it’s sketch version, only once.
With OpenHAB2 I was able to save the name, update a date variable and take trace when the sensor was rebooted the last time.
Now on Home Assistant I’m getting this information as well, in this way, with a sensor:

- platform: mqtt
  name: node21_sketchname
  state_topic: "mygateway1-out/21/255/3/0/11"
  retain: true

The update variable is with Home Assistant not needed, because, I’ve seen, if I press on the node21_sketchname variable, I can see the last time the variable was updated. Great! It matches the last reboot.
BUT, if I reboot Home Assistant, the value gets lost and so I cannot trace it’s uptime anymore.
Is there a way to restore on startup this value and let Home Assistant think this value was never in UNKNOWN state?

Other soggestions are well appreciated of course!

Thanks a lot!


Any idea? :innocent:


You could write the value to a file and read it back as needed???

The recorder will restore states on HA restarts for you.

Hello @firstof9 ,
Seems that this is not compatible with sensors… :frowning: the above are used as sensors, but if it’s wrong to use them as sensor, it’s ok to change it (in what?) :slight_smile:
@zarthan I would avoid using external files and handle updates then.
Other suggestions apreciated?