Template value adding several entities, but if one entity is unavailable whole calculation becomes unavailable

Hi team…
I’ve created total_power value template under which i’m adding all the power entities so i can get total power for entities i want to monitor.
If all entities are up everything works fine… issue becomes if i turn off one of devices from power… meaning entity is unavailable… total power becomes unavailable… is there a way to run the calculation where if entity becomes unavailable, value of such entity becomes zero so calculation continues without that entity???
This is what I got at the moment


value_template: '{{states("sensor.cab_1_power") | float + states("sensor.cab_2_power") | float 
+ states("sensor.cab_3_power") | float 
+ states("sensor.uph_1_power") | float + states("sensor.uph_2_power") | float 
+ states("sensor.heater_power") | float
+ states("sensor.spare_power_2") | float + states("sensor.lvl2_art_power") | float
+ states("sensor.pwrlvl1_power") | float 
+ states("sensor.prep_1_power") | float + states("sensor.prep_2_power") | float
+ states("sensor.homewares_power") | float 
+ states("sensor.fitup_power") | float + states("sensor.feather_power") | float
+ states("sensor.cut_1_power") | float
+ states("sensor.cut_2_power") | float + states("sensor.foam_power") | float
+ states("sensor.spare_power_3") | float + states("sensor.spare_power") | float
+ states("sensor.canteen_power") | float + states("sensor.lvl1sonos1_power") | float
}}'

I could see examples for individual template to check status but cant figure out how to do the calculation with those checks
Any help is greatly appreciated

If the template can’t be evaluated because one of the sensor values can’t be converted to a floating point number the whole template sensor will be disabled. There will be errors about this in your logs.

To fix this just add default values for all your | float filters, like this: | float(0), then if a sensor value is unavailable it will be replace with zero.

Another option is to use filters to get rid of sensors without state values and sum the states of the remaining entities…

value_template: |-
  {% set s_list = ["sensor.cab_1_power","sensor.cab_2_power", 
  "sensor.cab_3_power","sensor.uph_1_power","sensor.uph_2_power", 
  "sensor.heater_power","sensor.spare_power_2","sensor.lvl2_art_power",
  "sensor.pwrlvl1_power","sensor.prep_1_power","sensor.prep_2_power",
  "sensor.homewares_power","sensor.fitup_power","sensor.feather_power",
  "sensor.cut_1_power","sensor.cut_2_power","sensor.foam_power",
  "sensor.spare_power_3","sensor.spare_power","sensor.canteen_power",
  "sensor.lvl1sonos1_power"] %}
  {{ expand( s_list | select('has_value') )
  | map(attribute='state') | map('float') | sum }}

float(0) did the job!!
will also look at the filter part as I might have another project to which this will be ideal
Thank you!!!