I know this is a pretty well worn topic though I am asking again as it seems the “right way” has changed every 6 months and I am wondering the current best approach. Part of me says that there was a release in the past year that fixes this, but I can’t find the notes to that affect. In any event… I have a RESTful sensor:
- resource: http://192.168.73.10:9000/?command=get&proxyID=1721&variableID=1000
scan_interval: 900
sensor:
- name: "Front Parlor Remote Battery"
value_template: "{{ value_json['1000'] if (value_json['1000'] | int) > 0 else states('sensor.front_parlor_remote_battery_level') }}"
unit_of_measurement: '%'
device_class: battery
state_class: measurement
unique_id: front_parlor_remote_battery_percent
Note I filter out any values =0. This remote sleeps and when it does the gateway/controller reports a value of 0 so it isn’t useful. I just need to snag the value a few times a day when it phones home with it’s diagnostics OR is in active use.
Then upon a restart of Home Assistant, I get “unavailable” for this sensor and no value. How do I keep the sensor value through a restart? Ive seen this
I can of course just create an input_number worst case as a “last known good value” and update the template to use that instead of states(sensor). But again, is there a new native way to do it? Better way?