When nobody is home

Hi All,

Please bear with me, I’m new to Homey and am having trouble setting up a very simple flow. I want to do the following:


  • Nobody is home
  • and it is night


  • Turn on light X after random time
  • Turn off light X after random time

The second part I’ve figured out. The problem I’m having is that the only Presence flow card which makes sense is ‘when the last person leaves’. That’s not a state, but more a change in state. So my flow works for one night, but not the next night. There is no Presence card ‘when nobody is home’ and I don’t understand why. All my previous HA controllers used to have that function.

Any help greatly appreciated


  • it is getting dark
  • nobody is home

Yes thank, the issue is there is no Presence state ‘nobody is home’. Only ‘when the last person leaves home’, which is a change of state, but not a state. So this only works once, but not the next day anymore if I’m away for more than one day.

The presence cards are different for WHEN and AND, triggers and states.
So there is a card “No one is home”, the second one in the picture below.

Oh wow, thank you! That doesn’t make any sense at all, but you are right. But if I do it the other way around there is no more state ‘when it’s after sunset’, only ‘when the sun sets in X mins’. I. Guess I will just out 0 there. Great help, thank you.

Other question: so I switch lights on randomly with a delay of 50-270 mins. Then I want them to stay on for a random time and then go off. If I choose Switch off after X seconds, does it relate to when they switched on or is it counting from the beginning of the flow?

Edit: I’m confused what to choose when it says ‘Switch light off after X seconds’ and Delay of Y Minutes. I want to switch the light off after a random time AFTER it was switched on (not from when the flow started). Do I set this with X or Y?

Many thanks

Maybe you share your flow here, because it is not clear which cards you are using.
Most likely both cards switch off after X or Y seconds after the card is started, because how does the card know when the light is switched on?
Try this flow to get started:

  • WHEN light is switched on
  • Then switch of light with a delay of X minutes

Per definition a flow can only start with a trigger, not with a state.
Because “it is night” is true during the whole night. So when should the flow start?:wink:

Ah OK, got it, thanks!

Attached is my flow. What you mentioned above would be another, seperate flow, correct? Can I somehow embed this inside this flow? Otherwise it would always switch the light off after a certain time, even when I’m home.

All THEN cards run at the same time. So switching of has to be in a separate flow, you cannot embed. This flow for switching off can be started from the flow for switching on by adding “Start Flow …….” in the THEN part. Or by starting on a trigger “when the light is switched on”.
If you don’t want to switch off the lights when somebody is home, just also add AND “nobody is home”.

Ahh ok im starting to get it. Thank you so much for your help and patience!

So now I’ve seperate the glows for each light, then the flow triggers another flow which checks if the light is on and if so will switch it off after a random time. Hopefully that should work.


Ok, see how it goes and experiment a bit.
Just in case it doesn’t work out, just start with a simple flow that switches on a lamp at 18:00 hour and another flow that switches of that light at 08:00 hour. And then add some functionality step by step. That way you will understand what is happening. Otherwise you have one complex flow with a lot of uncertainties, that is with functions which work in a different way as you think. And then you will never understand what is going on.

1 Like

Hi TinTin,
first thing I thought about this topic is that it might be alreeady dark (night) whe the last person leaves.

So either you need a copy with another trigger
When… last person leaves
And… It is night

Or you start thinking about advanced Flows

And the other idea is, if you split it by making a flow occasionally switch lights on and off , which would work all nightyou can start it by just enabling that flow and stop it by disabling.

When … the last person leaves
Then… enable flow occasionally switch lights on and off


When … the first person enters
Then… disable flow occasionally switch lights on and off

Thanks Dirk, the issue is when I’m away for more than one day, the ‘when last person leaves’ only works on the first day. But @Rmb was right that I need to turn it around, ie the trigger is not when the last person leaves but when the sun goes down, and nobody is at home.

How would you do the flow you mentioned ‘turn lights on and off randomly’?

Maybe you can also do something with enabling/disabling flows.

Have this flow always active (trigger at midnight) and disable it when somebody comes home, enable it when the last person leaves.

Sounds interesting, but how would you combine the random switching on and off into a single flow?

You are right, but I proposed to use both -when it is turning night and if there is no one home, do it - and also, when the last person leaves and it is night , do it. Otherwise you will miss one event.

I have no clue how to switch light on and off randomly. I thought you had a sufficient solution. I just proposed to put it in a dedicated flow, that can be activated when needed or deactivated, when not. Unfortunately I did not find something like a random function for manipulating variables. Maybe there is one, maybe it can be done by Homey Script, which I am not yet used to. If I have such variable I could create a flow that does that function.

The way I have done it is I switch the lights on with a delay and as delay I put 20-300 minutes, so as soon as the sun sets, between 20 mins and 5h later the lights will switch on. Then it starts a seperate flow, which will switch the lights off after another random delay.

My idea is this one as advanced flow. So you can do it in one flow, without separated tasks.

you can add as many switches as you want - unfortunately advanced flows do not allow circles for an indefinite number.
To me it is still not satisfying, but it solves some issues:

  • It is one single flow
  • It doesn’t matter if the last person leaves before or after getting night
  • It works as expected, if you come home and even if you leave again

Please share your thoughts

1 Like

Wow, that looks great! I was trying to get to grips with simple flows first, but will try my luck with Advanced Flows now I guess. This also works if someone comes home after sunset and then leaves again.

Thank you for sharing this!

When somebody comes home after the lights have been switched on, all lights will still be switched off after a while :disappointed_relieved: