I am using a template sensor to obtain the POWER consumption which i then use to feed a Riemann helper. The code I use works perfectly in the HA DEVTools and it returns value or ZERO when no value available. As soon I deploy it and restart HA, the sensor returns Unavailable or Unknown. What is wrong in the code and any support to adjust? The idea is to have a Power sensor for the Riemann helper that never goes into a NO-NUMBER state.
# Power
- name: "TPL Shelly 3EM Grid net used Watt"
unique_id: tpl_shelly_3em_grid_net_used_power
state: >-
{{ max(0,
(states('sensor.shelly_3em_l1_power')|float if states('sensor.shelly_3em_l1_power')|float is number else 0) +
(states('sensor.shelly_3em_l2_power')|float if states('sensor.shelly_3em_l2_power')|float is number else 0) +
(states('sensor.shelly_3em_l3_power')|float if states('sensor.shelly_3em_l3_power')|float is number else 0)) | abs | round(2) }}
availability: >-
{{ [states('sensor.shelly_3em_l1_power'), states('sensor.shelly_3em_l2_power'), states('sensor.shelly_3em_l3_power')] | map('is_number') | max | default (0.0)}}
unit_of_measurement: W
state_class: measurement
device_class: power