"flow" is uitgeschakeld omdat deze Flow te vaak werd uitgevoerd

Een andere benadering voor wat je wil bereiken:
Ik heb een flow en een script die mij vertelt welke deuren/ramen nog openstaan bij regen op komst.
Dat moet om te bouwen zijn.
I.p.v. de trigger in mijn voorbeeldflow
“ALS regen werd groter dan 0mm”,
kun je bijv.
ALS de toezicht modus is gewijzigd
of
ALS de alarm vertraging is geactiveerd
als trigger gebruiken.

Flow:

/

Op de plek van het ? teken heb ik de variabele door_windowText geselecteerd.
Het script creëert en vult deze variabele met de inhoud van ‘windowText’, welke in het script gedefinieerd is.

Script (deur_raam-nog_open.js)
In Homeyscript maak je een nieuw script, noem hem bijv. deur_raam-nog_open.js
Copy/paste onderstaande code,
Onder het kopje \\ USER INPUT pas je de namen van de sensoren aan, en sla het script op:

// Homeyscript 'deur_raam-nog_open.js'
// Check if certain doors or windows is open?

let devices = await Homey.devices.getDevices();
let windowText = "";
let currentText = "";
let logText = "";
let windowOpen = false;
_.some(devices, device => 
{
if ( device.class == 'sensor' )
  {
  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:", device.name + " (device.class: " + device.class + ")"); 

// USER INPUT    
    // Enter contact sensors names, device.name == "Exact sensor name"
    // currenText = "Sensible sensor name"         
    if ( device.name == "FrontDoor x.1" ) currentText = "Front door";
    if ( device.name == "Deur Trap" ) currentText = "Trap";
    if ( device.name == "Deur Badkamer" ) currentText = "Badkamer";
    if ( device.name == "Raam Slaapkamer" ) currentText = "Slaapkamerraam";
    if ( device.name == "Deur Koelkast" ) currentText = "Koelkast";
    // End of user input

      if(currentText != ""){
      windowOpen = true;
      if(windowText=="")
      windowText = currentText;
      else
      windowText = windowText + ", " + currentText;
      }
    }
  }
});

if(windowOpen == true)
windowText = "These doors or windows are still opened: " + windowText;
else
// comment this out if you don't want a msg when all's fine:
windowText = "All doors and windows are closed";

//just to check
console.log("Output: ", windowText);

// Create / update HomeyScript variabele
await tag("door_windowText", windowText);

return (true);

Melding:

Met dank aan @RonnyW

1 Like