# Get notified when a device stops communicating

**URL:** <https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399>\
**Category:** Ideas & Suggestions\
**Created:** [January 21, 2023, 4:29pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399 "2023-01-21T16:29:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mackelito](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mackelito/32/8243_2.png) [@Mackelito](https://community.homey.app/u/Mackelito)\
**Post date:** [January 21, 2023, 4:29pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/1 "2023-01-21T16:29:16Z")

</div>

Every now and then I find aqara devices that has not been reporting new data for some time… would be nice if I could find out somehow.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 21, 2023, 5:58pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/2 "2023-01-21T17:58:03Z")

</div>

> [@How to check if a device is still online in any Homey network](https://community.homey.app/t/how-to-check-if-a-device-is-still-online-in-any-homey-network/74339/2):
>
> I made this flow for these kind of issues. You can import and use it: Install [Device Capabilities app](https://homey.app/en-us/app/nl.qluster-it.DeviceCapabilities/Device-Capabilities/) Go to app config Hit ‘Templates’ Hit “(Updated) Sensors Connection Check.” For further howto: hit “How to import an Exchanger file”

Also, I found out Ikea filament lights on Homey’s zigbee cause the Aqara’s to randomly stop sending updates.  
Works fine with Ikea sockets though.

---

<div class="post-metadata">

**Author:** ![Mackelito](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mackelito/32/8243_2.png) [@Mackelito](https://community.homey.app/u/Mackelito)\
**Post date:** [January 21, 2023, 6:45pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/3 "2023-01-21T18:45:32Z")

</div>

Will test the app and see…

About aqara/Ikea would you mind explaining some more… not sure I understand…

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 21, 2023, 7:14pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/4 "2023-01-21T19:14:29Z")

</div>

When I added Ikea filament lights to Homey’s zigbee, Aqara sensors which started to use them as zigbee hops, randomly stopped to send updates.  
Pairing the sensors again (w/o removing them first) solved it for a while.  
Then I replaced the Ikea with Lidl zigbee lights and the Aqara’s almost never stop sending updates anymore.  
So, for me, that combi of Aqara/Ikea lights didn’t work well.  
Aqara contact sensors didn’t seem to be affected, while they stick to the first route they find

---

<div class="post-metadata">

**Author:** ![Mackelito](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mackelito/32/8243_2.png) [@Mackelito](https://community.homey.app/u/Mackelito)\
**Post date:** [January 25, 2023, 10:02am UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/5 "2023-01-25T10:02:15Z")

</div>

Looked at the app and not really what I wanted but thx for the tip

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 25, 2023, 6:50pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/6 "2023-01-25T18:50:49Z")

</div>

Which app? It’s about the script, which checks the sensors

---

<div class="post-metadata">

**Author:** ![Mackelito](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mackelito/32/8243_2.png) [@Mackelito](https://community.homey.app/u/Mackelito)\
**Post date:** [January 25, 2023, 7:47pm UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/7 "2023-01-25T19:47:19Z")

</div>

[Device Capabilities app](https://homey.app/en-us/app/nl.qluster-it.DeviceCapabilities/Device-Capabilities/)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 26, 2023, 1:34am UTC](https://community.homey.app/t/get-notified-when-a-device-stops-communicating/75399/8 "2023-01-26T01:34:47Z")

</div>

…

The app is just the way to import my flow, nothing else 🥴

The flow itself is simple, so you’ll only need this:  
You need the _Then_ HS card “Run code with argument and return text-tag”

As argument, enter the time in seconds you want the script to consider a sensor unresponsive.

```auto
// Sensor.Check, to check on sensor last update time. Argument: inactive time (in seconds):

const INVALIDATE_AFTER = (args[0]); // Example 86400sec./3600 = 24hrs

const invalidatedDevices = [];
for (const device of Object.values(await Homey.devices.getDevices())) {
  if (! device.capabilitiesObj) continue;
  let count = 0;
  for (const capabilityObj of Object.values(device.capabilitiesObj)) {
    
    if (device.capabilitiesObj.measure_temperature || device.capabilitiesObj.alarm_contact || device.capabilitiesObj.alarm_motion ) { 

      if (! capabilityObj?.lastUpdated || (Date.now() - new Date(capabilityObj?.lastUpdated) > INVALIDATE_AFTER * 1000)) {
        count++;
        }
    }
  }
  if (count && count === Object.keys(device.capabilitiesObj).length) {
    invalidatedDevices.push("- " + device.name + "\n (zone: " + device.zoneName + ")" );
  }
}

// When there are matching sensors
if ( invalidatedDevices.length != 0 ) {
  // create / update HomeyScript variable
  await tag('InvalidatedDevices', invalidatedDevices.join('\n'));
  
  // Send Timeline notification
  Homey.flow.runFlowCardAction({
          uri: 'homey:manager:notifications',
          id: 'create_notification',
          args: {
            text: "\nDevices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n') + "\n\nflow Sensors Check"
          },
        });

  console.log("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n'));
  return("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n'));
}
  
// When there's no matching sensor
if ( invalidatedDevices.length == 0 ) {
  // Just report "None"
  // create / update HomeyScript variable
  await tag('InvalidatedDevices', 'None');
// Send Timeline notification
  Homey.flow.runFlowCardAction({
          uri: 'homey:manager:notifications',
          id: 'create_notification',
          args: {
            text: "\nDevices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: None\n\nflow Sensors Check"
          },
        });

  console.log("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: None" );
  return invalidatedDevices.length != 0;
}

// Original script by Robert Klep  
// https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/9

```
