links:sw-dev:homey:homey-scripts
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
links:sw-dev:homey:homey-scripts [2023-02-07 09:53] – created anders_admin | links:sw-dev:homey:homey-scripts [2023-02-07 09:57] (current) – [Check last update for devices] anders_admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Homey scripts ====== | ====== Homey scripts ====== | ||
- | ===== Check last update for units ===== | + | ===== Check last update for devices |
- | Source: https:// | + | Source: https:// |
< | < | ||
Line 22: | Line 22: | ||
await tag(' | await tag(' | ||
return invalidatedDevices.length != 0; | return invalidatedDevices.length != 0; | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | // Sensor.Check, | ||
+ | |||
+ | const INVALIDATE_AFTER = (args[0]); // Example 86400sec./ | ||
+ | |||
+ | 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? | ||
+ | count++; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | if (count && count === Object.keys(device.capabilitiesObj).length) { | ||
+ | invalidatedDevices.push(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // When there are matching sensors | ||
+ | if ( invalidatedDevices.length != 0 ) { | ||
+ | // create / update HomeyScript variable | ||
+ | await tag(' | ||
+ | | ||
+ | // Send Timeline notification | ||
+ | Homey.flow.runFlowCardAction({ | ||
+ | uri: ' | ||
+ | id: ' | ||
+ | args: { | ||
+ | text: " | ||
+ | }, | ||
+ | }); | ||
+ | |||
+ | console.log(" | ||
+ | return(" | ||
+ | } | ||
+ | | ||
+ | // When there' | ||
+ | if ( invalidatedDevices.length == 0 ) { | ||
+ | // Just report " | ||
+ | // create / update HomeyScript variable | ||
+ | await tag(' | ||
+ | // Send Timeline notification | ||
+ | Homey.flow.runFlowCardAction({ | ||
+ | uri: ' | ||
+ | id: ' | ||
+ | args: { | ||
+ | text: " | ||
+ | }, | ||
+ | }); | ||
+ | |||
+ | console.log(" | ||
+ | return invalidatedDevices.length != 0; | ||
+ | } | ||
+ | |||
+ | // Original script by Robert Klep | ||
</ | </ |
links/sw-dev/homey/homey-scripts.1675763628.txt.gz · Last modified: 2023-02-07 09:53 by anders_admin