Skip to content

Instantly share code, notes, and snippets.

@tkroo
Last active January 2, 2025 04:10
Show Gist options
  • Save tkroo/a192e110f4f454969a591962670d8d11 to your computer and use it in GitHub Desktop.
Save tkroo/a192e110f4f454969a591962670d8d11 to your computer and use it in GitHub Desktop.
{%- set mydata = namespace(mylist = states.sensor
| selectattr('attributes.device_class','defined')
| selectattr('attributes.device_class','in',['temperature'])
| rejectattr('entity_id','search','battery|average|slzb_06|proxy|dew_point')
| rejectattr('state','search','unavailable|unknown')
| list
,
unavailable = states.sensor
| selectattr('attributes.device_class','defined')
| selectattr('attributes.device_class','in',['temperature'])
| rejectattr('entity_id','search','battery|average|slzb_06|proxy')
| selectattr('state','search','unavailable|unknown')
| list
)
-%}
{%- set max = mydata.mylist
| map(attribute="state")
| max
| float
-%}
{%- set min = mydata.mylist
| map(attribute="state")
| min
| float
-%}
{%- set temps_list = mydata.mylist
| map(attribute="state")
| map('float')
| list
-%}
{%- set avg = (temps_list | sum / temps_list | length) | round(1) %}
## temps around the house
**average: {{ avg }} °F**
**warmest: {{ max }} °F**
**coolest: {{ min }} °F**
----
### {{ mydata.mylist | length }} sensor{{'s' if mydata.mylist|length != 1 }} reporting:
{%- for i in mydata.mylist | sort(attribute='state', reverse=true) %}
{{ i.name }}: **{{ i.state }} °F** {{ '(warmest)' if i.state|float == max|float }}{{ '(coolest)' if i.state|float == min|float }}
{%- endfor %}
{% if mydata.unavailable | length > 0 %}
### {{ mydata.unavailable | length }} sensor{{'s' if mydata.unavailable|length != 1 }} unavailable:
{%- for i in mydata.unavailable %}
{{ i.name }}: **{{ i.state }}**
{%- endfor %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment