A script to check sensor last update

Ah, so it’s a tag create/update error?
Hmmmm, what’s changed?
Can’t find anything here:

thnx, got a good tip from Peter_Kawa

thnx, this works. I also see some follow up on the THEN. Hope something good comes from this

1 Like

Not really, the problem is/was my misunderstanding of tag function - it do not return anything as Athom dev. said : “tag has no return value” - com.athom.homeyscript/app.js at 09d6d7397f7dcd6c001650aa7a1d3834d57734b6 · athombv/com.athom.homeyscript · GitHub

Both scripts updated

0.3b - fixed for THEN card (returning TEXT value), primary use-better use is for AND card though with variables/tag InvalidatedDevices / notReportingCount

General version

Zigbee version

1 Like

thnx. Zigbee 0.3b is working fine. Did not check the general 03.b

I love this script… :wink:

But I as well have the problem that some routers (powered devices) do not update their “last seen” when not used for a while. In my case only Ikea bulbs and sockets as well.
I would like to use the script mostly to report battery powered devices not reporting anymore because of a low battery (or failure of course).

Is it an option to include a/some line(s) in the script to exclude router devices, @Sharkys?
Or filter on router/end device?
I tried my best, but couldn’t find it… :frowning:

Added into version 0.4 :slightly_smiling_face:

2 Likes

Did I already mention you are the best?
And the quickest… :wink:

Thanks @Sharkys!

1 Like

I’m getting a

Failed: Getting ZigBee state TypeError: Cannot read properties of undefined (reading 'getState')
    at checkZigbeeLastSeen (Test.js:32:39)
    at Test.js:106:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

———————————————————
✅ Script Success
↩️ Returned: "Error in retrieving ZigBee state"

and :32 reads
const result = await Homey.zigbee.getState();

Running a fully updated HP23. Did I miss something?

This works @ Pro 2019, can you test it?

const result = await Homey.zigbee.getState();
log(result);
1 Like

yellow

If you have this Yellow flag, you must recreate the script as you are still using old version of HomeyScript.
Read more on Tutorial: Migrating deprecated scripts - HomeyScript

Long story short - create new script and copy paste the script from the previous version.

’m making a mistake somewhere. I’m using version 0.4 but for all devices, I get: NaN-NaN-NaN, NaN:NaN:NaN. Invalid value for time?

Am I doing something wrong…? Additionally, the script now indicates that all sensors are OK. But there’s one sensor that hasn’t responded for 3 days. (that’s why I want to use this script)

Did you just copy paste the script and run it and with log scrolled up, share the screen, eg:

alldevices

or

zigbee

1 Like

Thanks for taking a look. I copied the script exactly as is. I only changed the ReportingThreshold to 24. But even without that change, I’m still getting NaN-NaN-NaN.



Hm, interesting, Which Homey firmware version and HomeyScript you are on ?

Can you also go to Homey Developer Tools and launch :

Homey.Zigbee.getState();

And then copy here part like this one :
dev
(if you want, obfuscate ieeeAddr)

Homeyscript 3.5.1 and Homey is now on 11.0.0. Updated this morning, was on 10.0.10. (Homey Pro 2019).

I get this error with the launch of ‘Homey.Zigbee.getState();’

Should be Homey.zigbee.getState() (lower case ‘z’)

2 Likes

Ah! That worked indeed.

I don’t see any “lastSeen” like in your screenshot…

Damn autocorrect, although it shouldn’t touch code blocks :woozy_face:

1 Like