Question regarding the use of variables for advanced (?) flows

I just finished a very demanding period at work and wanted to dive a little deeper into flow handling.

First part is getting my motion sensors working sensibly, like giving me light if it’s night, but not if I haven’t gone to bed yet. My first thought that was variables, but I’m a little unsure how to properly implement them. Please help me out if you have any thoughts.

Step 1: create awake, asleep, away variables and I guess “yes/no variable” (binary) would suffice. Create flow to set “asleep” to no if “awake” changes to yes, create flow to set “awake” to no if “asleep” changes to yes. “Away” would be a manual thing, but I can include “if away is not yes” in my flows to begin with, and later add flows that will only trigger if it’s set to yes.

Step 2: set awake/asleep in the compound flows I use to set lighting for my whole apartment.

Question Is it possible to create a flow that will run if any light is turned on, except for certain ones, and not if they’re turned on from a flow?

Step 3: check for “asleep” in the flows triggered by motion detectors.

Anyone made something similar and would like to share?


Homey has built in Awake, Asleep and Away status so you could use that instead of variables.

You could use the < Group > app to do that.

That would probably require a variable. Set the variable in the flow that turns the light on and add a small delay to the actual switch on (so the variable is set before the light turns on). Then in the flow that responds to the lights turning on only run the task if the variable is false.
The problem is when to clear the variable.
One option would be to have an action that clears it in the the same flow that sets it but with a longer delay (long enough for the other flows to run). The difficulty is to decide how long the delays should be as too long and it might miss other events or too short and it clears before the other flows have run.
Another option is to clear it in the else section of the flow that runs when the lights turn on. If there is only one flow then this is the safest option but if there are more flows that relay on the variable then they will not see it being set.

1 Like

Thanks! I completely forgot about those built-in variables, but that should suffice at least for most scenarios - and I guess using the built-in ones will require less maintenance from my part :slight_smile:

1 Like