I have an MQTT topic that can reports a state that sometimes is an number and other times is a null value. How do I build a value template to perform the proper calculation if its a number but allow for the null when present?
For example the below works fine when the value is a number, however when the value flips to “null” I receive the log error “Exception in message_received when handling msg”
#Victron SmartShunt Runtime Remaining
- unique_id: victron_shunt_battery_timetogo
name: Battery Runtime Remaining
device_class: ENERGY_STORAGE
unit_of_measurement: 'kWh'
state_topic: "venus-home/N/serial#/battery/288/TimeToGo"
value_template: "{{(value_json.value / 3600) | round(0) }}"
icon: mdi:battery