Inacceptable huge default "sensor unavailable time" of 24 hours

This is what I made out of @amelchio 's great input (basically the same - just counts all incidents as sensor value and puts the affected devices in an attribute, accepts 2 hours (120 minutes) of missing status updates):

Sensor (replace: xxx and ZZZ - IP from and API token for deCONZ - and yyy as UID):

sensor:
  - platform: command_line
    name: Incidents Aqara-Devices Missing Status-Updates
    unique_id: yyy-yyy-yyy
    command_timeout: 60
    scan_interval: 1800
    command: 'curl -s http://xxx.xxx.xxx.xxx:40850/api/ZZZZZZZZZZ/sensors | jq -r "{ "devices": [ .[] | select(.manufacturername==\"LUMI\") | select(.lastseen < \"$(date -u -d@$(($(date +%s)-7260)) +%Y-%m-%dT%H:%M:%S)\")] | map(.name) | sort | unique, "total": [ .[] | select(.manufacturername==\"LUMI\") | select(.lastseen < \"$(date -u -d@$(($(date +%s)-7260)) +%Y-%m-%dT%H:%M:%S)\")] | map(.name) | sort | unique | length }"'
    value_template: "{{ value_json.total }}"
    json_attributes:
      - devices

Customize.yaml (just for a graphical view of the value):

sensor.incidents_aqara_devices_missing_status_updates:
  state_class: total
  unit_of_measurement: ""

At the end I added this sensor to my custom critical sensor monitoring to get a proper notification. “sensor.incidents_aqara_devices_missing_status_updates > 0” is the trigger - that’s one of the reasons why I wanted the sensor to have a numeric value (next to statistical and GUI reasons).

Thnx for explanation!

Has anyone an idea on how to exclude certain devices from the output?

Probably within the json_attributes “devices” itself - how to filter/remove (= ignore) elements of that array?

This way we could “silence” or whitelist/allowlist certain devices and this way reduce false positives for devices known to be less responsive in general (I got especially one of those kind).

Still no one with a proper attempt to exclude results (include a reject with a blocklist)?

Here’s a working solution, just in case one is interested.