Check if pre-defined entities have not changed in x?

Hi everybody,

I use zigbee2mqtt, which usually works fine, but sometimes entities become unavailable without reporting this to Home Assistant.

Is there a way to do the following

  1. define a list of entities to observe (for example, via group)
  2. define a time frame, let’s say 24 hours
  3. check whether any entity in this list has not changed either its state or perhaps even any of its attributes within this time frame
  4. if so, send a notification containing each entity that matches this criteria

Example: we have three sensors

  • binary_sensor.groundfloor_maindoor_contact
  • sensor.firstfloor_bedroom_readings_temperature
  • sensor.outside_backyard_motion_occupancy

Normally, either of these sensors should report a different state within the above mentioned 24 hour time frame. The door contact usually opens more than once per day, the temperature will definitely vary within 24 hours, and there will always be some sort of motion in the back yard within 24 hours.

Even if none of these things would happen for some reason, those sensors’ attributes would definitely change; below is an example of a Xiaomi Aqara temperature sensor’s attributes

applicationVersion: 3
dateCode: '20161129'
friendlyName: Flur/Messwerte
hardwareVersion: 30
ieeeAddr: '0x001d'
manufacturerID: 4151
manufacturerName: LUMI
model: WSDCGQ11LM
networkAddress: 40817
powerSource: Battery
softwareBuildID: 3000-0001
stackVersion: 2
type: EndDevice
zclVersion: 1

Humidity
49,41
Linkquality
58
Pressure
994,6
Temperature
17,9
Voltage
2.985

Even if the temperature, humidity, and pressure would not change at all, some other attribute might.

So there should be a way to observe this. I have noticed more than just a few times that some of those battery-powered sensors would just disconnect or run out of energy. An automation that would watch this for me and inform me when it’s time to check on those sensors would be phantastic, but I have no idea where to start.

Initial thought was to create an input_datetime per sensor, then create an automation that would write the current date and time to that input_datetime upon changing the corresponding sensor’s state - and then automate if those datetime had not changed in x hours. But perhaps there is a way without creating countless helpers that would just watch a predefined list of entites… is it?

Thank you in advance for your help :slight_smile:

Create an automation that runs in restart mode that triggers on amy change to your sensor. First action is input_boolean.idle turn off, followed by a 12 hour delay (or delay of your choice), followed by input_boolean.idle turn on. As long as it fires at least once every 12 hours the input boolean helper will never get turned on. Create another automation that triggers on time pattern (every 5 minutes with the condition that input_boolean.idle is on. Then set the action to whatever notification preference you have.