Advanced flow. Controleren of er nog lampen aan staan

Graag gedaan, Jasper.
Je was 2 dingetjes vergeten te veranderen (dat zie je wel in het script), maar dat maakt voor jouw script output niets uit verder

Ik wllde teveel tegelijk in het script denk ik :wink:
Probeer dit script eens!

// Which light/socket is still on?

let devices = await Homey.devices.getDevices();
let lightsText = "";
let currentText = "";
let logText = "";
let lightsON = false;
_.some(devices, device =>
{
if ( device.class == 'light' ||  
device.virtualClass == 'light' || 
device.class == 'socket' ) 
// device.class is found at https://tools.developer.homey.app/tools/devices

  {
  if ( device.capabilitiesObj &&
  device.capabilitiesObj.onoff &&
  device.capabilitiesObj.onoff.value )
    {
    // just to compare and check if there was no typo
    console.log("- Device:", device.name + " (device.class: " + device.class + ")");
    currentText = "";
    // Enter lights and sockets names, device.name == "Exact light/socket name"
    // currenText = "Sensible light/socket name"
    if ( device.name == "Eettafel lamp" ) currentText = "Eettafel lamp";
    if ( device.name == "Spots OSD achter" ) currentText = "Spots OSD achter";
    if ( device.name == "Gang beneden" ) currentText = "Gang beneden";
    if ( device.name == "Keuken lamp" ) currentText = "Keuken lamp";
    ///if ( device.name == "Spotjes keukenblad" ) currentText = "Staande Lamp";
    if ( device.name == "Spotjes keukenblad" ) currentText = "Spotjes keukenblad";
    if ( device.name == "Lamp Wc Beneden" ) currentText = "Lamp Wc Beneden";
    if ( device.name == "Spotjes voor" ) currentText = "Spotjes voor";
    if ( device.name == "Spotjes OSD voor" ) currentText = "Spotjes OSD voor";
    if ( device.name == "Spotjes badkamer" ) currentText = "Spotjes badkamer";
    if ( device.name == "Lamp gang boven" ) currentText = "Lamp gang boven";
    if ( device.name == "Slaapkamer inloop" ) currentText = "Slaapkamer inloop";
    if ( device.name == "Slaapkamer spotjes" ) currentText = "Slaapkamer spotjes";
    ///if ( device.name == "Lamp trapgat" ) currentText = "MuziekSet Power";
    if ( device.name == "Lamp trapgat" ) currentText = "Lamp trapgat";
    if ( device.name == "Lamp wc boven" ) currentText = "Lamp wc boven";
    if ( device.name == "Lamp deuren voor buiten" ) currentText = "Lamp deuren voor buiten";

      if(currentText != ""){
      lightsON = true;
      if(lightsText=="")
      lightsText = currentText;
      else
      lightsText = lightsText + "\n" + currentText;
      }
    }
  }
});

if ( lightsON == true )
lightsText = "De volgende lampen of stekkers staan nog AAN:\n" + lightsText + "\n";
/// ENglish:
// lightsText = "The following lights or sockets are still ON: " + lightsText;
else
// comment this out if you don't want a msg when all's fine:
lightsText = "Alle lampen en stekkers zijn uit";
/// ENglish:
// lightsText = "All lights and sockets are off";

// just to compare and check
console.log("\nOutput:\n", lightsText);

// Create / update HomeyScript variabele
await tag("lights_plugsText", lightsText);

return (true);