I am using an average sensor to get the average current temperature of a floor.
Sometimes when I reboot HA (such as after an update), my sensors report “0” as a current temperate for a moment. I’d like to ignore their value in my average when they report 0 and only use it when they don’t.
I tried using an if statement, but it gets convoluted and I’m not certain this is the most clean or efficient way, as I think I’d need to go in a for loop to go through all of them and stick their value in a temporary variable of some kind?
{% if state_attr('climate.thermostat_chambre_des_maitres', 'current_temperature'), 0 -%}
In this case ignore it
{%- else -%}
In this car use it
{{ state_attr('climate.thermostat_chambre_des_maitres', 'current_temperature')}}
{%- endif %}
{% set templist = [state_attr('climate.thermostat_chambre_des_maitres', 'current_temperature'),(state_attr('climate.thermostat_salle_de_bain', 'current_temperature')),(state_attr('climate.thermostat_chambre_megane', 'current_temperature')),(state_attr('climate.thermostat_cuisine', 'current_temperature'))] %}
{% for i in templist %}
{{i}}
{% endfor %}
This returns all 4 current temperatures as 0. I’d like to add them up, and divide by the number of non-zero items in the list.
This is where I’m somewhat stumped. I’m not sure I’m going about it the right way.