The flow with i million thenssss

Am I the right place… dont know! but here I go…

The dream: A bedtime flow → Trigger: I put my phone on charger… Easy! But here´s where my head starts to hurt. I would like that to trigger this → Lock all doors that arent already locked, turn off all lights, check if my car is plugged in and if not, how much battery it has left, aaaand! Check all of my door sensors and tell me through my google speaker in the bedroom, which if any of the doors or windows are open.

Can anyone tell me how I could accomplish this without creating around a gazillion different flows to activate with the “1 flow to rule them all”?

For now I make flows to govern Locks lights and car. But the sensors are killing me.

I have to create at least 2 different flows looking like this:

Trigger: Start this flow. ->When sensor1 on → Then TTS: “Sensor1”.
Let´s say I have 6 sensors, then I make 6 flows like this, followed by 2 flows like the next.

Trigger: Start this flow. ->When sensor1 on ‘or’ sensor2 on ‘or’ sensor3 on → Then TTS “Is open”, and disable next flow.

Trigger: Start this flow. ->When sensor4 on ‘or’ sensor5 on ‘or’ sensor6 on → Then TTS “Is open”, and disable previous flow.

If I set it up like this, and set a +2 second delay between every flow within “the flow to rule them all”, then the result would be, if sensor 1 and 3 were on. "Sensor 1… sensor 2… is open.

I wish that it was possible to add more ‘or’ steps than 3 in each flow, and more than that, if it was possible to add tags in Google TTS, so if I add 3 sensors in 1 flow, and two of them were on, then the TTS would only say which ones were on, and not mention the sensor that were off.

A customisable google TTS message if you will.

Maybe it´s already possible, maybe I´m just a moron, or maybe, just maybe, I gave you a perfect puzzle to fix.

Thanks for everyone who at least tried to read this mess.

I think this is the 1 million dollar question :grimacing:

.
Probably this, press on the v:

And with a warning through TTS, add something like this

So you want a million dollars to answer?:rofl: I agree though, and nice one with the tag in the TTS, however it wouldn’t fix my problem.

In 1 flow, I would like to determine which sensors is open, then tell me which is open, excluding those which is closed, so the tag should only be mentioned if it’s opened, and not if excluded.

Thanks for the answer though, enough of those, and the answer might reveal itself :+1:t6::blush:

From my personal perspective… a flow, which is triggered by the charger event and then calls out a script.

Yes, may-be seems not the easiest/simplest but actually, in realization phase with flows there may arise looooot of synchronization issues. Just a first example: When checking the opened/unlocked doors… does we want a lot of messages “Door 1 is open”, “Door 2 is open”… or want we a single message “Door(s) 1, 4, 6 are opened” ? In script - quite easy to collect into one string a message and if it’s not empty, then play at end. But in flow(s)… as i red from another thread, the charts in flow are executed in parallel :crazy_face: - just one first to comin’ in mind example.

That’s exactly what it does :wink:
In my examples only window ‘Raam Slaapkamer’ was open, it ignores the other sensors:

The tag is generated and updated every time the flow is triggered.

If all windows are closed,
the tag contains only what you enter after the last else . In my case “All doors and windows are closed”

......
else
windowText = "Alle deuren en ramen zijn dicht";
.....

My brain just melted… I think we´re agreeing on what I want, but how du I get to that script, that´s what eludes me. How du I get it to check the sensors and script it to me in one message, which sensors are open? Did you just explain it to me, or did you ask the same question, you understood my dilemma however :rofl:

My dutch is a bit rusty I guess, but how does your flow look, in order to just tell you which sensors are open, and not mentioning those that are closed. You are my hero, if you can explain it so I understand it. I’ll try to put on my braincap, so I can follow somewhat along :grin:

Hmm, in script may-be something like that.

// Get all devices
const devices = await Homey.devices.getDevices();
// Initiate the message string as empty
let message = "";
// Regexp to find out all the interesting windows 
const regexWindow = new RegExp('^window', 'i');

// Loop over all devices
for (const device of Object.values(devices)) {
  if ( device.class == 'sensor' || device.virtualClass == 'sensor'){  // The device is a sensor

    if ( regexWindow.test(device.name) ){ // Device name starts with "window..."
        // Remember there the 'device.id' value and use it in quicker script to loop over only the interesting sensors
        if ( device.capabilitiesObj.alarm_contact.value){ // So, was the contact alarm there
          if ( message === ""){ // If the message was totally empty, we need a introduction text to 
            message = "The next window(s) are opened: ";
          }
          message += device.name +" in "+device.zoneName+"; ";
        }
    }  
  }
}  


if ( message != "" ) log(message);
global.set("OpenedWindows",message);

Then You may use the global “OpenedWindows” in other flows-scripts to feed TTS or whatever You want (ok, the TTS is also possible to call within the same script)

NB! As You talked about doors, i about windows :wink: then possibly You must change the regexp of names. Reason, why i did so is that i have lot of window sensors in my house, but only one door. Also, may-be there is better to change the global device lookup with only some device ID’s in iterator array.

About “how we moved to script” - this was my recommendation to attempt to use a script instead of loooooot of different flows. By my own personal experience - if You must check multiple things in row, then the framework of flows is not the most user friendly thing. In script there is possibility to loop over objects, do multiple and nested IF/THEN’s etc.
Hope, the sample script explains reason of my recommendation… if not, then pls. attempt to do similar functionality for let’s say 5 windows with flows :wink:

Phew, gotta admit, it seems your suggestion is the way to go, unfortunately I´m no way near that level of intelligent, so it´s gonna take some time, learning to script. Just wanted to let you know, I´m working on it, but it might take some time, if I succeed I will post the script here, otherwise I will sob, also here, thanks for the suggestion though, it was the nudge I needed. Now I´m going to work :rofl: :call_me_hand:

I did it in advanced flows however is a really large flow.
However this only tells if there is:

  • 1 window open: tell which window
  • between 1 and 5: tell how many windows are open
  • 5 windows open: tell all windows are open

After it has been run, it sets a variable to false. This makes sure the flow is only run once every 30min.

The ‘start a flow’ cards are flows to start Google TTS on the various devices throughout the house.

Khmm :wink:


With:

1 Like