Template sensor count devices in a range?

I have the following code:

    high_temp:
      friendly_name: 'High Temperature Reported'
      unit_of_measurement: devices
      value_template: >-
        {% set ignore_entities = ['redacted'] %}
        {{ states.sensor
          | selectattr('attributes.device_class', 'eq', 'temperature')
          | rejectattr('entity_id', 'in', ignore_entities)
          | rejectattr('entity_id', 'search', 'battery|wleak|magnet|color|motion')
          | map(attribute='state')
          | map('float') | select('gt', 85)
          | list | count
        }}

This tells me when any of the sensors are reporting a temperature above 85 degrees. However, when my HVAC system resets (read: When I reboot home assistant and HomeKit refuses to reconnect so I have to pull the T-stat off the wall to reboot it), as the remote sensors for that come back online they briefly read 212 degrees for a short period of time. However, it is a LONG enough period of time that it still triggers an alert.

How can I modify the line “map(‘float’) | select(‘gt’, 85)” so that it only includes devices greater than 85 AND less than 200 in the count? I searched the forums here for a bit and couldn’t find any examples of this syntax anywhere…

Any help is greatly appreciated.

Thanks!

map('float') | select('gt', 85) | select('lt', 200)

1 Like

Awesome, thank you!