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).