Highest humidity room name

I’ve got 8 switchbot temp. sensors (one in each room) where I’d like to get the room name and humidity of the highest registered humidity.

I read that you could get the value by using the min/max value, but not sure how to find the area from that sensor if that’s even possible?

Thanks!

Try this to get a room name & max value:

{% set SET =
     states.sensor |
     selectattr('attributes.device_class','defined') |
     selectattr('attributes.device_class','eq','humidity') |
     list
%}
{%
  set MAX = 
    SET |
    map(attribute='state') |
    map('float',default=0) |
    list |
    max
%}
{% set AREA =
   (
     SET |
     selectattr('state','eq',MAX|string) |
     map(attribute='entity_id') |
     map('area_id') |
     list
   )[0]
%}

Hope someone will reduce it to one line)))

P.S. Does not account a “several values have same max value”.
For this - do not use “[0]”, process a whole list.

P.P.S. Do not forget to exclude entities related to an outdoor weather from the “SET” variable.

I would suggest you use a “Combine the State…” (aka Min/Max) Helper to get the Max value. Then you can use it’s attributes to get the area name:

{{ area_name(state_attr('sensor.example_max_humidity', 'max_entity_id')) }}

While this does require that you add new sensors manually