Sorry for the inconvenience.
I just checked, and the updated version is different.
Now I don’t understand how the 3 homeyscript cards and that script ended up with your flows after the import. When did you imported the TEF? Not recently?
I just imported the TEF twice, to make sure, and it is the one I expect; there’s one Homeyscript card in it, and this is te code in it:
// Sensor.Check, to check on sensor last update time. Argument: inactive time (in seconds):
const INVALIDATE_AFTER = (args[0]); // Example 86400sec./3600 = 24hrs
const invalidatedDevices = [];
for (const device of Object.values(await Homey.devices.getDevices())) {
if (! device.capabilitiesObj) continue;
let count = 0;
for (const capabilityObj of Object.values(device.capabilitiesObj)) {
if (device.capabilitiesObj.measure_temperature || device.capabilitiesObj.alarm_contact || device.capabilitiesObj.alarm_motion ) {
if (! capabilityObj?.lastUpdated || (Date.now() - new Date(capabilityObj?.lastUpdated) > INVALIDATE_AFTER * 1000)) {
count++;
}
}
}
if (count && count === Object.keys(device.capabilitiesObj).length) {
invalidatedDevices.push("- " + device.name + "\n (zone: " + device.zoneName + ")" );
}
}
// When there are matching sensors
if ( invalidatedDevices.length != 0 ) {
// create / update HomeyScript variable
await tag('InvalidatedDevices', invalidatedDevices.join('\n'));
// Send Timeline notification
Homey.flow.runFlowCardAction({
uri: 'homey:manager:notifications',
id: 'create_notification',
args: {
text: "\nDevices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n') + "\n\nflow Sensors Check"
},
});
console.log("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n'));
return("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: \n" + invalidatedDevices.join('\n'));
}
// When there's no matching sensor
if ( invalidatedDevices.length == 0 ) {
// Just report "None"
// create / update HomeyScript variable
await tag('InvalidatedDevices', 'None');
// Send Timeline notification
Homey.flow.runFlowCardAction({
uri: 'homey:manager:notifications',
id: 'create_notification',
args: {
text: "\nDevices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: None\n\nflow Sensors Check"
},
});
console.log("Devices without updates for " + INVALIDATE_AFTER / 3600 + "hrs: None" );
return invalidatedDevices.length != 0;
}
// Original script by Robert Klep
// https://community.homey.app/t/a-script-to-check-sensor-last-update/63142/9
YW! Yes, the previous version returned all of your sensors with a timestamp for you to check, the current version only returns the ‘faulty’ sensors.
But, I’ve tried some things, and this works, but at this time only for one sensor capability. I can’t get my head around how to use a wildcard for that.
In this case, I would like to wildcard the capabilities measure_temperature , alarm_sensor and alarm_contact
//// invalidatedDevices.push("- " + device.name + "\n (zone: " + device.zoneName + ")" ); Original line
// test with timestamps
invalidatedDevices.push("- " + device.name + " - " + device.capabilitiesObj?.measure_temperature?.lastUpdated?.substring(0,16) + "\n (zone: " + device.zoneName + ")" ); // WORKS, but only for one SENSORTYPE
Hm, thank you, honestly I would be not able to figure that condition myself … it’s a pity it doesn’t work for others sensors. Peter, would you mind to share a condition, how to exclude specific devices names from check ? That’s possibly the only / last thing missing
If I explain it well:
That way you can be in control over which THEN cards, to which a value is set, can trigger the common WHEN card or not.
Personally I would like to be “and trigger flowcards” the default Then card option, instead of “and do nothing”. Or, make the default option set-able in the app settings.
Because you might only want to have it triggered when changing through the API, Homey App or Web App.
Perhaps i can buildin a option to change the default, but because the option was buildin later, i build it like this to not break existing flows at that time.
Thanks for the explanation. Something like the old virtual devices to “turn them on without trigger”. Default trigger would indeed be better in my opinion. Thanks Arie!
Hi @Arie_J_Godschalk,
with the actually Homey TestFlight app for iOS devices v6.11.12 (1039) it’s not possible to create a new AVD. It’s not possible to change the name of the AVD and then save it. The problem is that the keyboard isn’t available.
I guess it’s Homey app related, but I just wanted to inform you about this issue.