They are basically the same thing. But i think it might be the time meeting this up so going to move from condition to restriction
Away lighting simulator not triggering automatically
So should the restriction go at the very highest level of the piston so that it covers all the logic or only so that it restricts the first if logic?
Like this? Note I’ve also added the ‘Cancel all pending tasks’ action as the return to home logic still wasn’t working like I want it to. Haven’t tested after adding that action yet.
OK thanks. And sorry if this is a silly question but how can I test whether this will trigger when I need it to without testing it when we’re actually out?
copy it to a new piston. Pause the original. Then change the main if to if time is any
and set the restriction to a time that encompasses the current time or a few minutes into the future so you can test both ways. Then set your SHM to armed away.
Save and then click on test
Still can’t get this to trigger automatically I’m totally stumped because I can’t see anything wrong with the logic, but I see nothing in the logs apart from the two presence devices being confirmed as away and that’s it. Could it be that after registering the presence devices as away the Piston times out before the time condition is met and that’s why it’s not triggering on its own? Because the whole scenario involves waiting for a particular time of day after the presence devices are away, before triggering the rest of the logic.
Secondly, the statement in the second if to set the ‘hasSomeoneArrived’ variable to true isn’t being executed. I’ve checked through the logs and that statement is just not being executed. Any idea why? It means my landing light gets turned off as part of the turn all off action when the second presence device is detected as present.
Ok I get what is going on then. I think you will need to split this up into a piston that controls your presence/mode/SHM and then another piston for your away simulator.
Well, this might sound silly now but I already have ‘Away’ mode and ‘I’m back’ pistons. The away mode piston sets the location mode and SHM to Away if the presence devices are away and SHM is not already away. The I’m back piston sets the location mode to home and SHM to disarmed if any of the presence devices becomes present. These are working fine - so what are you suggesting the issue is with the away lighting simulator?
Edit: Hang on, I think I know what you mean. Why am I checking for presence status of presence sensors AND SHM status when I only need to check for SHM status - the SHM status will be set based on presence sensors as part of my other Away mode piston…yes?
Your edit is correct. No need to check the same thing multiple times. So you should be able to get rid of your if and just have the while statement as it is inside the if statement.
OK so the piston now looks like the below. Do I still need the ‘only when’ restriction separate to the while condition or can I merge them?
Also, any suggestions for why the ‘hasSomeoneArrived’ variable isn’t being set to true? I’ve moved it up in the ‘then’ statement to be the first thing that happens in case that helps.
Maybe your cancel all pending tasks is stopping things before the variable has been set.
Have you tried putting in a small delay, say 5 seconds?
Might do the trick.
I’ve now put the set variable action above cancel all pending tasks so that should prevent that scenario no? Where would i put the 5 second delay?
I would put it between these 2 statements.
Give a chance for the variable to be set before cancelling all the tasks.
EDIT:
Perhaps start with a bigger wait time to make sure it works first.
Then bring the wait time down.
Got it OK - I will do that. I’ll go for say 10 seconds to start with.
Edit: What does cancel all pending tasks actually do? The point of using it is to stop all the random lighting automation stuff happening in the first if statement. What I don’t want is for it to mess with the logic in the second if to turn all lights off and turn landing light on.
You can probably get rid of the cancel tasks.
And yes you can put the time back into the while
OK, I’ve now rejigged the piston by removing the cancel tasks, moving the time restriction into the while and also basing the if condition of the second if on SHM rather than presence. I realised by doing this that I also don’t need the ‘hasSomeoneArrived’ variable anymore because the SHM status will only ever ‘change to’ Disarmed once when the first presence sensor is detected. When the second presence is detected, the SHM status will not be away so the actions shouldn’t be repeated a second time.
Piston as it is below - will be testing later: