Offline detection devices blueprint

I took the blueprint from Home Assistant Blueprint: Offline detection for Z2M devices with last_seen · GitHub as a basis.
At the moment, we managed to get a list of devices for the “unavailable” telegram in the form
Offline detect 03
"sensor.100 connected line

  • sensor.100 dtmf received
  • sensor.100 dtmf sent
  • sensor.100 state
  • sensor.101 connected line
  • sensor.101 dtmf received
  • sensor.101 dtmf sent
  • sensor.101 state
  • sensor.102 connected line
    Who knows how to correctly add device exceptions “| rejectattr(‘entity_id’, ” specified in
    exclude:
    name: Excluded Sensors
    Code
blueprint:
  name: Offline detection devices with last_seen 03
  description: Regularly test all sensors with 'last_seen' in name and 'timestamp' device_class
    ('last seen' Z2M sensors) to detect offline and if so execute an action.
  domain: automation
  input:
    hours:
      name: Hours not seen
      description: Sensors not seen this amount of time are assumed to be offline.
      default: 24
      selector:
        number:
          min: 1.0
          max: 168.0
          unit_of_measurement: h
          mode: slider
          step: 1.0
    time:
      name: Time to test on
      description: Test is run at configured time
      default: '10:00:00'
      selector:
        time: {}
    day:
      name: Weekday to test on
      description: 'Test is run at configured time either everyday (0) or on a given
        weekday (1: Monday ... 7: Sunday)'
      default: 0
      selector:
        number:
          min: 0.0
          max: 7.0
          mode: slider
          step: 1.0
    exclude:
      name: Excluded Sensors
      description: "'last seen' sensors (from devices that you want to exclude) to
        exclude from detection. Only entities with 'last seen' in name and 'timestamp'
        in device_class are supported, devices must be expanded!"
      default:
        entity_id: []
      selector:
        target:
          entity:
            domain: sensor
    actions:
      name: Actions
      description: Notifications or similar to be run. "\"{{sensors|replace(\"_\",\" \")}}\"\t" is replaced with
        the names of sensors being offline.
      selector:
        action: {}
  source_url: https://gist.github.com/Mr-Groch/bf073b142b507e3b6f8154223f81803b
variables:
  day: !input 'day'
  hours: !input 'hours'
  exclude: !input 'exclude'
  sensors: >
    {% set ignore_seconds = 60 %}
    {% set ignore_ts = (now().timestamp() - ignore_seconds)|as_datetime %}
    
    {% set result = namespace(sensors=[]) %}
    
    {{ states.sensor 
    | selectattr('state', 'eq', 'unavailable') 
    | rejectattr('domain','in',['button','event','group','input_button','input_text','scene'])
    | rejectattr('entity_id','search','browser_')      
    | rejectattr('entity_id','search','_alarm_volume|_next_alarm|_alarms')
    | rejectattr('entity_id','contains','_memory_percent')
    | rejectattr('entity_id','in',integration_entities('hassio'))
    | rejectattr('entity_id', 'eq' , 'sensor.entity_blacklist')
    | map(attribute='entity_id')|list|sort|join('\n- ') }}
trigger:
- platform: time
  at: !input 'time'
condition:
- '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}'
action:
- choose: []
  default: !input 'actions'
mode: single

I’m not a programmer.

The Blueprint Exchange is intended as an area for people to share a blueprint they have written.

If you are having a problem with a specific Blueprint, the first point of contact is in the Exchange (or Github) post that you found the Blueprint in originally.

There are people there using the equipment and the blueprint and will be able to give you more accurate information regarding your problem.

Don’t fall into the Streetlight Effect.

I will be moving this post to the appropriate topic.