# A script to check sensor last update

**URL:** <https://community.homey.app/t/a-script-to-check-sensor-last-update/63142>\
**Category:** Questions & Help\
**Tags:** homeyscript\
**Created:** [April 29, 2022, 7:44am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142 "2022-04-29T07:44:44Z")\
**Posts on this page:** 20\
**Page:** 5

<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:** [July 22, 2024, 8:23pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/84 "2024-07-22T20:23:07Z")

</div>

> [@Sjoerd1](#):
>
> I don’t see any “lastSeen” like in your screenshot…

Hmm, I’m not sure, maybe LastSeen is not available for Homey 2019, if such case, you would need to use the other script.

@Peter_Kawa ,Peter, I guess you are not using this script for Zigbee, right? (just to verify LastSeen)

---

<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:** [July 22, 2024, 10:00pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/85 "2024-07-22T22:00:07Z")

</div>

Hi Sharkys,

Can’t help indeed, I’m using Zigbee2mqtt.

---

<div class="post-metadata">

**Author:** ![Sjoerd1](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sjoerd1/32/33892_2.png) [@Sjoerd1](https://community.homey.app/u/Sjoerd1)\
**Post date:** [July 23, 2024, 8:49am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/86 "2024-07-23T08:49:19Z")

</div>

The Homey version was indeed the problem. The other script (0.3b) is working on Homey Pro 2019 🙂.

Thanks for taking a look.

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [July 28, 2024, 4:07pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/87 "2024-07-28T16:07:57Z")

</div>

Thanks - awesome! I was looking for something to check on my Zigbee devices 😃

But…is there a way for me to only act if there are more than 0 devices in the list? Maybe have the script end with an error?

---

<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:** [July 28, 2024, 9:12pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/88 "2024-07-28T21:12:08Z")

</div>

> [@Tiwas](#):
>
> if there are more than 0 devices in the list

It returns variable / value tag already and you can act based on it

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [July 29, 2024, 3:34am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/89 "2024-07-29T03:34:59Z")

</div>

Hmmm…I have a card for HomeyScript returning a text tag. Is there a way to access the other tags? I get one tag, the #result. If I read the script correctly, should I have access to an #InvalidatedDevices and #notReportingCount ? If so, care to point me in the direction of which card to use instead of the HomeyScript returning text tag? Or…how to access the other variables if the text tag is done correctly?

---

<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:** [July 29, 2024, 11:38am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/90 "2024-07-29T11:38:17Z")

</div>

Only the `return` command gets passed to the cards’ tag.  
When you need multiple results, just write them to Homeyscript tags, which you can use in flowcards like device tags, and logic variables.

```auto
/*
 * This script will create a few Tags for use in Flow.
 * It will remove them after 5 seconds.
 */

// Create Tags
log('Creating My String...');
await tag('My String', 'abcdef');

log('Creating My Number...');
await tag('My Number', 123);

log('Creating My Boolean...');
await tag('My Boolean', true);

log('Creating Kitchen Light, false, true, value...');
await tag('Kitchen Light, false, true, value', 'NewValue');

// Wait 15s
for (let i = 0; i < 15; i++) {
  log('.');
  await wait(1000); // in milliseconds
}

// Delete Tags
log('Deleting My String...');
await tag('My String', null);

log('Deleting My Number...');
await tag('My Number', null);

log('Deleting My Boolean...');
await tag('My Boolean', null);

log('Deleting [Kitchen Light, false, true, value]...');
await tag('Kitchen Light, false, true, value', null);

return(true);

```

---

<div class="post-metadata">

**Author:** ![Tiwas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tiwas/32/10066_2.png) [@Tiwas](https://community.homey.app/u/Tiwas)\
**Post date:** [July 29, 2024, 12:00pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/91 "2024-07-29T12:00:19Z")

</div>

Awesome! Thanks! I wasn’t aware of that possibility. I did see the tags being created, but I wasn’t aware that they would be available anywhere but the flowcard’s output. This was awesome 🙂

---

<div class="post-metadata">

**Author:** ![Henk\_Renting](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/henk_renting/32/87634_2.png) [@Henk\_Renting](https://community.homey.app/u/Henk_Renting)\
**Post date:** [January 17, 2025, 3:06pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/92 "2025-01-17T15:06:06Z")

</div>

Would it also be possible to exclude a certain folder in this script, @Sharkys?

I usually put devices that I am playing around with, or not always plugged in (Christmas lighting, etc) in a certain folder. Would be nice if you could exclude such a folder from the script as well…

---

<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:** [January 17, 2025, 8:07pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/93 "2025-01-17T20:07:29Z")

</div>

> [@Henk\_Renting](#):
>
> Would be nice if you could exclude such a folder from the script as well

Check out 0.4 & 0.5 Zigbee only versions.

> [@A script to check sensor last update](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/25):
>
> Updated script I posted above - added counter of non responding devices - eg, in case you would like to initiate some action based on number of not-responding devices - please note this is the version I’m using, so feel free to change relevant variables below the section // Filter devices to check Changelog : 0.1 - update - converting notReportingCount to a number - if you used previous version of script, delete tag by await tag(‘notReportingCount’, null);\* 0.2 - added filtering based on dev…

> [@A script to check sensor last update](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/39):
>
> As there is for some time options to see Lastseen timestamp for Zigbee devices, here is the script for Zigbee devices only, which might be more accurate for Zigbee devices. Thanks @Caseda for your overview script wink Version 0.3 - updated for HomeyScript v. 3.5.1 Version 0.3b - fixed for THEN card (returning TEXT value), primary use-better use is for AND card though Version 0.4 - added option to filter out routers and/or end devices // Version 0.4 // Script checks LastSeen property of Zig…

---

<div class="post-metadata">

**Author:** ![Henk\_Renting](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/henk_renting/32/87634_2.png) [@Henk\_Renting](https://community.homey.app/u/Henk_Renting)\
**Post date:** [January 17, 2025, 8:26pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/94 "2025-01-17T20:26:25Z")

</div>

Damn, you’re quick!  
Thanks a million! 👍🏻😃😃😃

---

<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:** [January 17, 2025, 8:45pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/96 "2025-01-17T20:45:59Z")

</div>

So both versions updated + made it little bit more user friendly + quickly tested, hopefully it will be working fine for everyone.

---

<div class="post-metadata">

**Author:** ![PeterHa](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@PeterHa](https://community.homey.app/u/PeterHa)\
**Post date:** [January 17, 2025, 10:31pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/97 "2025-01-17T22:31:24Z")

</div>

Hi @Sharkys ,  
I’m not a DEV, but for me it looks like that the zigbee script (version 0.5) is not (only) for Zigbee.  
I adapted the filter in line 14, and I see also non-zigbee devices.

---

<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:** [January 17, 2025, 11:41pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/98 "2025-01-17T23:41:44Z")

</div>

You are actually right, mistake happened.

---

<div class="post-metadata">

**Author:** ![ricercar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ricercar/32/101928_2.png) [@ricercar](https://community.homey.app/u/ricercar)\
**Post date:** [January 18, 2025, 10:53am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/99 "2025-01-18T10:53:28Z")

</div>

Hello,  
I am new to this thread and at a loss to find version 0.5 (stuck with 0.4).  
Could you please point me to 0.5 ?

---

<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:** [January 18, 2025, 11:09am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/100 "2025-01-18T11:09:34Z")

</div>

If you are looking for Zigbee version, it’s WIP (just limited by time). The other is just above ,scroll few posts back.

---

<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:** [January 18, 2025, 3:06pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/101 "2025-01-18T15:06:33Z")

</div>

You can test Zigbee 0.6 version.

---

<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:** [January 18, 2025, 3:45pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/102 "2025-01-18T15:45:12Z")

</div>

**Changelog (any device type) :**

**Version 0.5** - better output formatting and fixes date times sometimes N/A

> [@A script to check sensor last update](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/25):
>
> Updated script I posted above - added counter of non responding devices - eg, in case you would like to initiate some action based on number of not-responding devices - please note this is the version I’m using, so feel free to change relevant variables below the section // Filter devices to check Changelog : 0.1 - update - converting notReportingCount to a number - if you used previous version of script, delete tag by await tag(‘notReportingCount’, null);\* 0.2 - added filtering based on dev…

**Changelog (Zigbee only) :**

**Version 0.6** - improved formatting of the output

> [@A script to check sensor last update](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/39):
>
> As there is for some time options to see Lastseen timestamp for Zigbee devices, here is the script for Zigbee devices only, which might be more accurate for Zigbee devices. Thanks @Caseda for your overview script wink Version 0.3 - updated for HomeyScript v. 3.5.1 Version 0.3b - fixed for THEN card (returning TEXT value), primary use-better use is for AND card though Version 0.4 - added option to filter out routers and/or end devices Version 0.5 - added option to exclude ZONES, moved varia…

---

<div class="post-metadata">

**Author:** ![PeterHa](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@PeterHa](https://community.homey.app/u/PeterHa)\
**Post date:** [January 18, 2025, 11:40pm UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/103 "2025-01-18T23:40:26Z")

</div>

The new version is much easier to configure and to maintain. Thanks @Sharkys for that.

I’m using the script in a card and send the output with a push notification to me if a device is nok.  
In the new version are devices excluded in EXCLUDED\_DEVICE\_NAME\_PATTERN also listed in the output. I think it would make sense if the output would be without these devices.  
I’m not 100% sure, but I think it was handled in this way in the previous version(s).

---

<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:** [January 19, 2025, 7:07am UTC](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/104 "2025-01-19T07:07:40Z")

</div>

> [@PeterHa](#):
>
> In the new version are devices excluded in EXCLUDED\_DEVICE\_NAME\_PATTERN also listed in the output.

Hm, you mean Zigbee version, right ? …hopefully fixed

[Previous page](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142.md?page=4)

[Next page](https://community.homey.app/t/a-script-to-check-sensor-last-update/63142.md?page=6)
