My flower sensors send temperature values, so they are reported between the temperature sensors
However, I made a mistake in the flow, the contact sensor check was added twice
You can replace the script in the last HomeyScript flowcard, with this code below.
The TEF file is also updated, you can just import it again.
Code (clickme)
// Sensor.Temperature_Check, to check Temperature sensors connection by comparing last update times
let array = [];
const devices = await Homey.devices.getDevices({ filter: {class: 'sensor', capabilities: 'measure_temperature'} });
_.forEach(devices, device => {
array.push( device.name + '\t==> ' + device.capabilitiesObj?.measure_temperature.lastUpdated?.substring(0,16) );
});
//oldest date on top sort array = ["time_stamp device", "time_stamp device", "time_stamp device" ]
const array_sorted = array.slice().sort(function(time_stamp, device) {
const firsttime_stamp = time_stamp.split(" ")[0];
const secondtime_stamp = device.split(" ")[0];
if(firsttime_stamp < secondtime_stamp) return -1;
if(firsttime_stamp > secondtime_stamp) return 1;
return 0;
});
console.log("Temperature sensors:\n" + array_sorted.join('\n') + "\n\nSensor.Temperature_Check.js");
Homey.flow.runFlowCardAction({
uri: 'homey:manager:notifications',
id: 'create_notification',
args: {
text: "Temperature sensors:\n" + array_sorted.join('\n') + "\n\nSensor.Temperature_Check.js"
},
});
return array_sorted.join('\n');