Skip to content

Instantly share code, notes, and snippets.

@tkroo
Created December 3, 2024 05:43
Show Gist options
  • Save tkroo/dcf9822052fd4900c14fae4712e382f4 to your computer and use it in GitHub Desktop.
Save tkroo/dcf9822052fd4900c14fae4712e382f4 to your computer and use it in GitHub Desktop.
# create helper > template > Template a sensor
# put the code below in the State template field
{%- set tempslist = states.sensor
| selectattr('attributes.device_class','defined')
| selectattr('attributes.device_class','in',['temperature'])
| rejectattr('entity_id','search','battery|average|slzb_06')
| rejectattr('state','search','unknown|unavailable')
| map(attribute='state')
| map('float')
| list
-%}
{{ (tempslist | sum / tempslist | length) | round(2) }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment