A script to check sensor last update

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)

Hi Sharkys,

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

1 Like

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

Thanks for taking a look.

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

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?

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

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?

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.

/*
 * 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);
2 Likes

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 :slight_smile:

1 Like