# A flow to identify inactive sensors (values) / unavailable devices

**URL:** <https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808>\
**Category:** Questions & Help\
**Created:** [August 2, 2023, 9:45am UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808 "2023-08-02T09:45:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 9:45am UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/1 "2023-08-02T09:45:40Z")

</div>

I’ve tried to search through different topics without luck.  
Is there any way to create a flow that notifies if a sensor value hasn’t changed/updated in, say 24 hours?

I basically want a notification if a sensor (eg. Aqara or Sonoff temp.) hasn’t changed.

I created this flow to identify unavailable devices, but I haven’t since I just created it, I haven’t had an alert yet.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/5/a5b9b30986576826244ddd8b212c14fc1044b969.png)

I’m aware of this topic where a script has been used, but I’m not sure if it works and how to implement it?

> [@A script to check sensor last update](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/26):
>
> I used this in HS to force a value to be considered numeric, not sure if it works inside the tag arguments tag('notReportingCount', Number(notReportingCount)())

---

<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:** [August 2, 2023, 12:54pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/2 "2023-08-02T12:54:29Z")

</div>

Hej Jesper

You can use this importable flow (use the [Device Capabilities app](https://homey.app/a/nl.qluster-it.DeviceCapabilities/) for it);  
Including a how-to and script:

> [@The Flow Exchange(r) - Exchange Your Flows with Others!](https://community.homey.app/t/the-flow-exchange-r-exchange-your-flows-with-others/68981/13):
>
> Sensor (or any device) Connection Check. Sometimes, you’ll discover a sensor or other device doesn’t report it’s status or value anymore, but it does NOT notify you of being offline… Well, this flow checks the, most recent update time of your sensors. You can run the flow every day, twice a day, just add or remove a time triggercard. The ‘inactive time’ can be edited as well (24hrs as default) and you can choose to not send notifications when all sensors did report inside the ‘inactive time…

You can even import it right away using the app configuration, and pick “Templates”:

 ![Screenshot from 2023-08-02 14-52-17](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/0/40eeb57dfc681d3b3bad3f8de262040bef23335e.png)

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 1:35pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/3 "2023-08-02T13:35:49Z")

</div>

Hi Peter,

Thanks for helping out.  
I’m not sure what to put here when importing the flow?

Can you help me out?  
I’m an absolut noob in homey script and also at importing flows 😃  
**UPDATE: Never mind - I figured it out 🙂**  
Thaks again 😃

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/8/88c6d0ae2069ace06375f0c35bfb74bb2d32bd7e.png)

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 1:49pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/4 "2023-08-02T13:49:08Z")

</div>

@Peter_Kawa now I have this issue instead 😕

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/5/b511ab4006d5262d28a55a030d8f426c1449632d.png)

---

<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:** [August 2, 2023, 1:49pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/5 "2023-08-02T13:49:41Z")

</div>

Just hit “Update Text” and when you see code appear, hit the link “Homey API Playground”  
This screen pops up, but first fully clear the input field with the default examples, and then CTRL + V (or use paste with the mouse menu)  
Scroll back up, and hit the blue “Run” button.

 ![Screenshot from 2023-08-02 15-46-53](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/e/de70212858627b5f811eda127b6255522e1b7efe.png)

When it succeeded, go back to the previous screen, it should show a link with the created flow:

> ![Screenshot from 2023-08-02 15-52-17](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/b/bb887244c4742a47bd5182283ee35aab1838574e.png)

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 1:54pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/6 "2023-08-02T13:54:32Z")

</div>

I still get this error 😕

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/4/0491d90d8c2c63c7d1cc902a7d676cfe3326b97f.png)

---

<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:** [August 2, 2023, 1:57pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/7 "2023-08-02T13:57:13Z")

</div>

Read the howto again. This card is a dummy card, which has to be replaced by the real Homeyscript card by you.

> ![Screenshot from 2023-08-02 15-58-30](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/4/54bc0b7ce940cdd3d90085ad8ef36d08c597a8b1.png)

Oh, the card bottom left can be deleted (little error on my side).

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 2:15pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/8 "2023-08-02T14:15:52Z")

</div>

Arh sorry for my incompetence 😃

One final little quirk now is that it returns the following headline “_Devices without updates for **NaN** hrs / **NaN** days_”

Will this solve itself or am I doing something wrong?

Thanks again for helping out 🙂

---

<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:** [August 2, 2023, 2:28pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/9 "2023-08-02T14:28:29Z")

</div>

NaN = Not a Number  
Did you use the right Homeyscript card?

---

<div class="post-metadata">

**Author:** ![petomei](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/petomei/32/21348_2.png) [@petomei](https://community.homey.app/u/petomei)\
**Post date:** [August 2, 2023, 2:31pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/10 "2023-08-02T14:31:38Z")

</div>

> [@Yestond](#):
>
> One final little quirk now is that it returns the following headline “_Devices without updates for **NaN** hrs / **NaN** days_”

You have to choose the HomeyScript Flowcard\* “Run Code with Argument and return Text-tag” and insert 43200 in the Argument section:  
 ![Bildschirmfoto 2023-08-02 um 16.27.29](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/1/a11332ce4e64c235778a9294d3be40f5b4d3b42b.png)  
 ![Bildschirmfoto 2023-08-02 um 16.30.11](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/b/2b6052e62e839c1740ad2bed1abf513537c96c69.png)  
Then it should work.

\*there is a little mistake in @Peter_Kawa 's video

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 7:15pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/11 "2023-08-02T19:15:51Z")

</div>

> [@petomei](#):
>
> 43200

Thank you both.  
I needed to set the argument like you said @petomei  
Thank you @Peter_Kawa for you contribution as well. I know you’re a very active member in the community - great work!

---

<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:** [August 2, 2023, 7:26pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/12 "2023-08-02T19:26:20Z")

</div>

The vid is from a similar “card swap”, and there’s no argument used. I thought “get the picture” would suffice.  
Should I make a vid for the specific flow you think?

I also tested the homeyscript card without entering the seconds in the argument field, and it just returned _all_ sensors, not `NaN`… not sure what was different

But I’m glad it works now, Jesper! @Yestond

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 2, 2023, 7:51pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/13 "2023-08-02T19:51:17Z")

</div>

Is there any way to only show certain censors like motion and temperature. Right now Chromecast values and other non-relevant values are part of the updates as well?

---

<div class="post-metadata">

**Author:** ![Torch1969](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/torch1969/32/33305_2.png) [@Torch1969](https://community.homey.app/u/Torch1969)\
**Post date:** [August 2, 2023, 7:58pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/14 "2023-08-02T19:58:23Z")

</div>

> [@Yestond](#):
>
> I’ve tried to search through different topics without luck.  
> Is there any way to create a flow that notifies if a sensor value hasn’t changed/updated in, say 24 hours?

This thread has some usefull suggestions

> [@A script to check sensor last update](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142):
>
> Hello everyone, In my home set-up I have a bunch of Aqara sensors directly connected to a Homey that I use to monitor temperature and humidity (and for some of them, to trigger some automations based on those). Overtime they run out of battery and I only realised it when the automations don’t start or for the “passive” ones, only when I dive a little deeper in the Insights section. My idea was to use a script to read at a regular interval (say every day) the last updated value of a given senso…

---

<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:** [August 2, 2023, 8:07pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/15 "2023-08-02T20:07:40Z")

</div>

> [@Yestond](#):
>
> Is there any way to only show certain censors like motion and temperature.

Yes you can adjust the code starting at line 10 - ish

```auto
    // Exclude by app names virtual devices and other app devices
    // (find correct app names via https://tools.developer.homey.app/tools/devices and look for "Driver")
    if (device.driverUri.match('vdevice|DeviceCapabilities|chronograph|betterlogic|devicegroups|callmebot|netscan' )) continue;
    // Exclude by (parts of) device name
    if (device.name.match('^se|^pr|TST|z_|z |z. |IR|rris|eboo|rada|KNM|Timeline|#1|#0|ESP|esp|TV C|TV S|iffu|Unav|Wekk|OUD|OLD|Peter|Custom|Afval|LEDs')) continue;

```

You can change it to something like this:

```auto
    // Exclude by app names
    // (find correct app names via https://tools.developer.homey.app/tools/devices and look for "Driver")
    if (device.driverUri.match('appNameYouDontWant|OtherAppNameYouDontWant')) continue;
    // Include by app names
    if (!device.driverUri.match('appNameYouWant|OtherAppNameYouWant')) continue;
    // Exclude by (parts of) device name
    if (device.name.match('nameOfSensorYouDontWantToCheck|nameOfOtherSensorYouDontWantToCheck')) continue;
    // Include by (parts of) device name
    if (!device.name.match('nameOfSensorYouWantToCheck|nameOfOtherSensorYouWantToCheck')) continue;

```

> [@Yestond](#):
>
> Chromecast values and other non-relevant values are part of the updates as well

They should be excluded afaik, not included …  
When I comment out (=disable) the “if (device.driverUri…” line, they all appear here, and I don´t want that:

```auto
    // Exclude by app names
    // (find correct app names via https://tools.developer.homey.app/tools/devices and look for "Driver")
    ////if (device.driverUri.match('vdevice|DeviceCapabilities|chronograph|betterlogic|devicegroups|callmebot|netscan' )) continue;

```

---

<div class="post-metadata">

**Author:** ![To\_Lou](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/to_lou/32/79159_2.png) [@To\_Lou](https://community.homey.app/u/To_Lou)\
**Post date:** [August 2, 2023, 9:18pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/16 "2023-08-02T21:18:24Z")

</div>

I would like the script to include say after 24h (86400) but NOT after 48h to produce a syslog entry every day with unique devices.

Struggled with the  
`if (! capabilityObj?.lastUpdated || (Date.now() - new Date(capabilityObj?.lastUpdated) > INVALIDATE_AFTER * 1000)) { count++; }`

to add another constraint for also exclude doubled time without success…

Any suggestions?

Also would like to throw an error if no devices match criteria, and NOT produce a empty log entry.

@robertklep

---

<div class="post-metadata">

**Author:** ![Yestond](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/yestond/32/9807_2.png) [@Yestond](https://community.homey.app/u/Yestond)\
**Post date:** [August 3, 2023, 6:21am UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/17 "2023-08-03T06:21:06Z")

</div>

Perfect @Peter_Kawa. That did the trick. Thank you again 😉

---

<div class="post-metadata">

**Author:** ![Anders\_Gregow](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/anders_gregow/32/61721_2.png) [@Anders\_Gregow](https://community.homey.app/u/Anders_Gregow)\
**Post date:** [August 3, 2023, 7:19am UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/18 "2023-08-03T07:19:02Z")

</div>

> [@Yestond](#):
>
> Is there any way to create a flow that notifies if a sensor value hasn’t changed/updated in, say 24 hours?

The Device capability app has a card to retrive latest change for a device and its capability. The value will be in millisec so compare it to 24_3600_1000. I am doing this for my important devices, works great.

---

<div class="post-metadata">

**Author:** ![To\_Lou](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/to_lou/32/79159_2.png) [@To\_Lou](https://community.homey.app/u/To_Lou)\
**Post date:** [August 3, 2023, 8:05pm UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/19 "2023-08-03T20:05:23Z")

</div>

Leaning towards Device Capabilities and ‘Duration till now’ result tag. This way there’s only one minimum duration instead of multiple LastUpdated records.

But how to call the ‘Retreive Insights’ THEN flowcard from a Homeyscript?

```auto
const { result: response } = await Homey.flow.runFlowCardAction({
  uri: 'homey:app:nl.qluster-it.DeviceCapabilities',
  id: 'homey:app:nl.qluster-it.DeviceCapabilities:action_capability_log',
  args: {
    device: 'Motion Sensor 1',
    capability: 'Motion alarm',
    numberof: 0,
  },
});
log(response);

```

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mike_d/32/67788_2.png) [@Mike\_D](https://community.homey.app/u/Mike_D)\
**Post date:** [April 21, 2024, 7:43am UTC](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808/20 "2024-04-21T07:43:55Z")

</div>

Hi, I used this flow and it works, only issue I have is that every device is being listed as no communication in last 12 hours. For example though, I see some devices have communicated with homey in that time. Does anyone have any ideas. Is there a way to check the last communication time for an individual device?

[Next page](https://community.homey.app/t/a-flow-to-identify-inactive-sensors-values-unavailable-devices/85808.md?page=2)
