Bitteschön ![]()
// Check if certain doors or windows is open?
let devices = await Homey.devices.getDevices();
let zones = await Homey.zones.getZones();
let windowText = "";
let currentText = "";
let logText = "";
let windowOpen = false;
_.some(devices, device =>
{
if ( device.class == 'sensor' )
// device.class is found at https://tools.developer.homey.app/tools/devices
{
if( device.capabilitiesObj &&
device.capabilitiesObj.alarm_contact &&
device.capabilitiesObj.alarm_contact.value )
{
currentText = "";
// to compare and see if there is no typing error
//console.log(`- Open door/window script check: \nName: ${device.name} \nZone: ${device.zone} \n(ZoneName: ${device.zoneName}) \n[device.class: ${device.class} \ndevice.capabilities: ${device.capabilities}]`);
if(device.name != ""){
let zone = zones[device.zone];
windowOpen = true;
if(windowText=="")
windowText = device.name + "\t(Zone: " + zone.name + ")";
else
windowText = windowText + "\n" + device.name + "\t(Zone: " + zone.name + ")";
}
}
}
});
if(windowOpen == true)
windowText = "\nDiese Türen oder Fenster sind offen:\n" + windowText + "\n";
else
// comment this out if you don't want a msg when all's fine:
windowText = "Alle Türen und Fenster sind geschlossen.";
Homey.flow.runFlowCardAction({
uri: 'homey:manager:notifications',
id: 'create_notification',
args: {
text: windowText + '\n[Bernd Unterwegs - Tür/Fenster Offen Meldung]'
},
});
//just to check
console.log("\nOutput:", windowText);
// Create / update HomeyScript variabele
await tag("door_windowText", windowText);
return (true);