# How to monitor device still being active?

**URL:** <https://community.homey.app/t/how-to-monitor-device-still-being-active/83239>\
**Category:** Questions & Help\
**Created:** [June 26, 2023, 12:38pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239 "2023-06-26T12:38:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Articate](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/articate/32/57311_2.png) [@Articate](https://community.homey.app/u/Articate)\
**Post date:** [June 26, 2023, 12:38pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239/1 "2023-06-26T12:38:49Z")

</div>

Before we used to have the ability to say “if a sensor hasn’t responded in x time” flow card, but that seems gone, now. Some devices in our home are pretty crucial, and sometimes they stop responding for a plethora of reasons. Sometimes it’s wifi related, other times it’s Zigbee, or what have you.

But I’d like to ensure that my temperature sensors have updated in at least an hour. My current idea is to have a timer that starts counting down, that you reset to an hour every time that sensor updates a value. But that’d be a lot of unique timers and values to keep track of.

Does anyone have a neater way of doing it?

---

<div class="post-metadata">

**Author:** ![Sharkys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sharkys/32/54029_2.png) [@Sharkys](https://community.homey.app/u/Sharkys)\
**Post date:** [June 26, 2023, 2:10pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239/2 "2023-06-26T14:10:52Z")

</div>

> [@\[APP\]\[Pro\] Wireless Weather Sensors - Reads data from several brands of wireless weather sensors](https://community.homey.app/t/app-pro-wireless-weather-sensors-reads-data-from-several-brands-of-wireless-weather-sensors/23532/140):
>
> You can give [this script](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/22) a go. It searches for the last update time of (filtered) devices from X hours ago When X is set to, say, 24, all devices without any update for the last 24hrs get reported. Example

…eg. I’m using Advanced flows and checking different devices types differently

---

<div class="post-metadata">

**Author:** ![Paul](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/paul/32/12987_2.png) [@Paul](https://community.homey.app/u/Paul)\
**Post date:** [June 26, 2023, 3:01pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239/3 "2023-06-26T15:01:23Z")

</div>

I think the function : If a sensor hasn’t responded in x time, is still available (at least on my pro 2016/2019).  
Home → scroll down : A device hasn’t reported in.

 ![Screenshot_20230626_165146_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/9/49fea7b2e197d5cd0d0786be0b45e98d29a3fd0f.jpeg)

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [June 26, 2023, 3:04pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239/4 "2023-06-26T15:04:23Z")

</div>

Homey Pro (early 2023) has this function removed as it was a pretty heavy function and pretty unreliable.

Athom has talked about re-adding it, but “per device” and not a “for every device in a zone”.  
For now it is just talk, have seen no evidence of it yet.

---

<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:** [June 26, 2023, 3:15pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239/5 "2023-06-26T15:15:39Z")

</div>

Yeah that triggercard caused flows to get disabled while ‘started too many times’ (Classic Pro 2019).  
The mentioned script is a much better way imho, also for the 2023

---

<div class="post-metadata">

**Author:** ![Articate](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/articate/32/57311_2.png) [@Articate](https://community.homey.app/u/Articate)\
**Post date:** [June 26, 2023, 11:22pm UTC](https://community.homey.app/t/how-to-monitor-device-still-being-active/83239/6 "2023-06-26T23:22:25Z")

</div>

Thank you! That’s an excellent idea. I’ll be using this.

I took the liberty to rewrite your code to more efficiently and in a more readable manner to check for unresponsive devices:

```auto
const reportThresholdMs = 60 * 60 * 1000
const reportThreshold = new Date(Date.now() - reportThresholdMs);

let devices = await Homey.devices.getDevices();

function isRelevant(device) {
  if (device.class.match(/sensor|camera|thermostat/i)) {
    return true;
  }

  return false;
}

function isUnresponsive(device) {
  let unresponsive = true;

  // So long as one capability is updated after reportThreshold,
  // the device is considered responsive.
  Object.values(device.capabilitiesObj).forEach(capability => {
    let lastUpdated = new Date(capability.lastUpdated ?? 0);
    if (lastUpdated > reportThreshold) {
      unresponsive = false;
    }
  });
  return unresponsive;
}

let devicesToCheck = Object.values(devices).filter(isRelevant);
let unresponsiveDevices = Object.values(devicesToCheck).filter(isUnresponsive);

let unresponsiveDevicesNames = Object.values(unresponsiveDevices).map(device => device.name);
log(unresponsiveDevicesNames);

```

The last two lines is just an example of how to retrieve the list. the “isRelevant” function is barebones, but shows how you can implement more checks on matching. I’ll start the implementation of actually using this tomorrow.
