A script to check sensor last update

Something like

uri: 'homey:manager:notifications',
id: 'create_notification',
args: {
text: 'Test text sent by Timeline_message.js'

1 Like

and how this rows can put the script end or how? Advanced flow not showing all information like when script test run?

Why you would need that ? You can process output tags and to whatever you want in flows.


because my aqara wireless wall switch battery status report not valid the app, and today is 2. wall switch is not working because the battery is low down and app say 100% status and I want to now if something devices is low battery
But if you have any solution how make a flow I’m listening. Thanks

Zigbee ? If it’s Zigbee I would recommend to use A script to check sensor last update - #39 by Sharkys otherwise use A script to check sensor last update - #25 by Sharkys

The flow is quite trivial :

…add some trigger (time, condition based or any you want).
There is also check included in this example to ensure you will not get repeated notifications about the same devices.

thanks, no have any script that can read zigbee and device correct battery status, that is I like. thanks for your time help me.

Great job, this is exactly what i was looking for.

additional question:
If a device is not updating this “lastseen” date itself, how do I automaticly PING this device. (with a script)
Just about the same question like this.

You can’t.

What’s wrong with the script, it finds anything which hasn’t show any signs of life for the last xx hrs

IKEA Repeaters do not correctly update Last seen value - no idea why but I guess it"s Homey Zigbee issue or some incompatiblity. My advice (and what I did as well), filter it out in the script or stop using IKEA.

That makes no sense :thinking: A “last seen” value is something that Homey determines.

Repeater: “Hey Homey, you last saw me yesterday!”
Homey: “No I didn’t, I’m seeing you right now!”
Repeater: “…”


Yep and still, it doesn’t work with IKEA, I have no idea why. Now I looked on my Ikea Tradfri power socket - last seen two weeks ago :-)) Also there is some problem with storing / restoring this Last seen values upon restart - for some devices it’s reset upon restart, again no idea why. Submitted to Athom 2 / 3 weeks ago.

What command is send from the development page with the “PING” button?
After that the ‘lastseen’ date/time has a new value.

You can try for yourself (replace “AA:BB:CC” with the full IEEE address of a device you want to ping):

  "opts": { "ieeeAddr":"AA:BB:CC" },
  command: 'PING'

This works from the Web API Playground, but not from HomeyScript, so it cannot be automated.

Updated both scripts to be compatible with Homeyscript 3.5.1 and later (now default, when new Homeyscript is created)

General version

Zigbee version

Those scripts are not compatible anymore with Homeyscript <3.5.1 and older, which is called “Classic”


Hello Sharkey,
trying to use the script as replacement to use Homey script 3.5.1 but get error: “Invalid token type: string. Expected: String”
HomeyPro23 version 11.0.0
Would you know why this occurs since the script seems to be in use by others?

I am using a modified version of @Sharkys script, but do not know why you are getting the error. As you are waiting for @Sharkys , maybe you can post the script so i can help you as good as i can?

1 Like

Hi Derf,

I got a similar error when using the THEN card ‘Run code and return text-tag’
The script works fine though, only returning the output to the text-tag seems to be the problem
Screenshot from 2024-05-19 01-48-07

Screenshot from 2024-05-19 01-48-27

In Homeyscript console, and with the AND ‘Run code’ card, there are no problems. As script output, you’d use the generated HS tags as shown in my Timeline card:

1 Like

Ah, I see, thanks Peter ! I have never used THEN, only as AND card :wink:
However in my case, the error message is quite weird …

{"message":"Invalid token type: string. Expected: String"}

…I do hope it’s not similar issue like with await Homey.zigBee.getState(); vs await Homey.zigbee.getState();

Btw even this simple example return error…


FYI - asking Athom if this is a bug or not

update it’s not a bug, script must be updated (but you can still use it just for THEN it will return the error but the variables gets updated

1 Like