{% 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.