I wish to average 24 hourly forecasts to get an average daily temperature, which I then use to determine whether to heat or cool the house. I currently have the following:
- platform: template
sensors:
average_forecast_temperature:
friendly_name: "Day's Forecast Average"
value_template: "{{ average(state_attr('weather.openweathermap', 'forecast')[0]['temperature'],state_attr('weather.openweathermap', 'forecast')[1]['temperature'],state_attr('weather.openweathermap', 'forecast')[2]['temperature'],state_attr('weather.openweathermap', 'forecast')[3]['temperature'],state_attr('weather.openweathermap', 'forecast')[4]['temperature'],state_attr('weather.openweathermap', 'forecast')[5]['temperature'],state_attr('weather.openweathermap', 'forecast')[6]['temperature'],state_attr('weather.openweathermap', 'forecast')[7]['temperature'],state_attr('weather.openweathermap', 'forecast')[8]['temperature'],state_attr('weather.openweathermap', 'forecast')[9]['temperature'],state_attr('weather.openweathermap', 'forecast')[10]['temperature'],state_attr('weather.openweathermap', 'forecast')[11]['temperature'],state_attr('weather.openweathermap', 'forecast')[12]['temperature'],state_attr('weather.openweathermap', 'forecast')[13]['temperature'],state_attr('weather.openweathermap', 'forecast')[14]['temperature'],state_attr('weather.openweathermap', 'forecast')[15]['temperature'],state_attr('weather.openweathermap', 'forecast')[16]['temperature'],state_attr('weather.openweathermap', 'forecast')[17]['temperature'],state_attr('weather.openweathermap', 'forecast')[18]['temperature'],state_attr('weather.openweathermap', 'forecast')[19]['temperature'],state_attr('weather.openweathermap', 'forecast')[20]['temperature'],state_attr('weather.openweathermap', 'forecast')[21]['temperature'],state_attr('weather.openweathermap', 'forecast')[22]['temperature'],state_attr('weather.openweathermap', 'forecast')[23]['temperature'])|round(1)}}"
unit_of_measurement: °F
device_class: temperature
This works perfectly, but is extremely verbose. Is there a more effecient way to express the template? Thank you.