Away lighting simulator not triggering automatically

triggers

#57

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.


#58

You can probably get rid of the cancel tasks.

And yes you can put the time back into the while


#59

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:


#60

Can you force a subscription on the SHM statement in the while loop?


#61

Yep, so I’ve said ‘Always subscribe’ to that and can see a little ‘+’ sign next to the SHM condition. But shouldn’t I do that to the time condition instead of the SHM one?


#62

I think you could probably get away with it. If you still have your test one try both


#63

can you try on line 42 use ''else ''should work or ''async if ‘’ in line 24, try this one first let me know


#64

Sorry I don’t quite understand what you mean…


#65

There is no if on line 24. The reason for the async if on 42 is leftover from trying to trouble shoot this piston before.


#66

try something like this in your piston


#67

So basically replace the while loop with an ‘async if’…?

Could you just explain how and why you think that will help please?


#68

If the previous statement includes a Wait task, all the remaining tasks in the previous statement, and any statement after that, will be delayed pleas read the link below and let me know if that work
https://wiki.webcore.co/Execution_Method


#69

But I don’t want the actions after the wait task to be executed until the wait period has elapsed. Wouldn’t making the whole loop asynchronous mean that the piston will proceed to turn off the randomly selected light and send me a push notification even though the wait period hasn’t elapsed? If so, that’s not what I want. I do however want the if logic below the while loop to be processed even if the while loop is in the middle of it’s logic. I want the if logic to interrupt the while loop if a presence sensor arrives, exit out of the while loop and proceed with the actions in the if logic.


#70

ok, can you try line 25 with if and line 42 with else


#71

OK I need to test it as it is and if it doesn’t work I will try your suggestion.


#72

I am going to use this as a model for my vacation lighting. I noticed you arent repeating after line 35. Did you plan to only have it run once?


#73

Sorry which screenshot are you referring to line 35 in? Have what run once?


#74

I thought this was trying to repeat the steps?


#75

This Piston will continue to turn a random light on for a random number of minutes and then off again between sunset and 1am when we are away. When we get back the Piston breaks out of its loop.


#76

What did your final script look like? I am still having trouble with mine.