links:sw-dev:homey:homey-scripts
This is an old revision of the document!
Table of Contents
Homey scripts
Check last update for devices
Source: https://community.homey.app/t/app-pro-insight-trends-reloaded/71307/103
const INVALIDATE_AFTER = 86400; 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 (! capabilityObj.lastUpdated || (Date.now() - new Date(capabilityObj.lastUpdated) > INVALIDATE_AFTER * 1000)) { count++; } } if (count && count === Object.keys(device.capabilitiesObj).length) { invalidatedDevices.push(device.name); } } await tag('InvalidatedDevices', invalidatedDevices.join(', ')); return invalidatedDevices.length != 0;
links/sw-dev/homey/homey-scripts.1675763644.txt.gz · Last modified: 2023-02-07 09:54 by anders_admin