Hi,
I have an MQTT sensor that reports the SOC of my storage battery, I have several autoimations that depend on that sensor value. Last night all the MQTT sensors from the REST went offline/unavailable and therefore my automations (to charge the battery) did not pass their conditional requirements.
I also have the same SOC value available via an integration but it lags by some time compered to the MQTT value. So what I would like to do is template the MQTT sensor so that it first uses the MQTT value, but if that is unavailable to use the integration sensor value.
This is what i tried to do but it doesn’t pass configuration checks:
- name: "Battery SOC MQTT fallback"
state_topic: "Sofar2mqtt/state"
value_template: "{{ value_json.batterySOC }}"
availability:
- topic: "Sofar2mqtt/state"
payload_available: "online"
payload_not_available: "{{ ('sensor.sofar_battery_soc') }}"
unit_of_measurement: '%'
Could any one with more experience help to guide me to fix the template or is there another / better way to substitute a sensor value?
Thank you,