jchh
((not John))
1
Hi,
I am trying tio get the highest temp from a ranger if sensors.
I took my start point from this thread. I am just trying with 2 at the moment but cannot get it to work. Can someone give me a pointer?
template:
- sensor:
- name: "hottest temp"
device_class: temperature
unit_of_measurement: ℃
state: >
{% set sensors = [
states('sensor.hallway_temp'),
states('sensor.living_room_temp')]
|reject('none')|list
%}
{{ sensors |round(1) | max }}
jchh
((not John))
2
OK, got it. Keeping this here in case it helps someone else…
{% set sensors = [
states('sensor.hallway_temp') |round(1),
states('sensor.living_room_temp') |round(1)]
|reject('none')|list
%}
{{ sensors | max }}
jchh
((not John))
3
Does anyone know what template would give the ‘friendly name’ of the hottest sensor?
Here is one way to do it:
{% set sensors = expand('sensor.hallway_temp', 'sensor.living_room_temp') %}
{% set x = sensors | map(attribute='state') | map('float') | max | string %}
{{ sensors | selectattr('state', 'eq', x) | map(attribute='name') | first }}
tom_l
5
You could just use the min max integration:
2 Likes
myle
(StePhan McKillen (Other kiwi Here))
6
this is how i did it
- platform: min_max
name: lounge temperature max
type: max
entity_ids:
- sensor.lounge_temperature
- sensor.lounge_temperature_max
jchh
((not John))
7
Brilliant - thanks.
I am now going to read up on expand()
, map()
& selectattr()
jchh
((not John))
8
@Tom_in_HI @myle
Thanks for your replies, guys
Doesn’t min_max
gives you the min and max for each entity listed? I am looking for which entity is max right now.
tom_l
9
No.
e.g. feed it 6 sensors, it will tell you the maximum value of the six states.
1 Like
jchh
((not John))
10
Oh, fantastic - thanks for explaining that!
myle
(StePhan McKillen (Other kiwi Here))
11
remember to pass it else into the min_max
- platform: min_max
name: lounge temperature max
type: max
entity_ids:
- sensor.lounge_temperature
- sensor.lounge_temperature_max
so that the max will be the max
and can do the same for the min