Help with piston to control a number of lights


#1

1) Give a description of the problem
Just the first lights command is working.

2) What is the expected behavior?
That all the lights will come on when someone arrives home and then they all turn off at 11:00pm

3) What is happening/not happening?
Just the first DO statement is working (undercabinet lights). The other lights aren’t coming on.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
12/13/2017, 5:03:09 PM +369ms
+0ms ╔Received event [Home].mode = Home with a delay of 84ms
+327ms ║Runtime (41448 bytes) successfully initialized in 262ms (v0.2.100.20171211) (325ms)
+328ms ║╔Execution stage started
+399ms ║║Executed [Under Cabinet Lights].on (11ms)
+411ms ║║Executed [Under Cabinet Lights].setLevel (8ms)
+415ms ║║Executed virtual command [Under Cabinet Lights].waitForTime (2ms)
+416ms ║║Requesting a wake up for Wed, Dec 13 2017 @ 8:00:00 PM EST (in 10610.216s)
+423ms ║╚Execution stage complete. (95ms)
+426ms ║Setting up scheduled job for Wed, Dec 13 2017 @ 8:00:00 PM EST (in 10610.208s), with 2 more jobs pending
+437ms ╚Event processed successfully (438ms)
REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

The ‘wait till 8pm’ in your first ‘with’ block is holding everything else up… webCoRE defaults to synchronous so the next ‘with’ block won’t fire until the first block completes.

Click on the first ‘with’, click the cog symbol and change it to asynchronous so the following parts don’t need to wait in line.

Do the same for any other blocks containing long waits.


#3

You could also simplify things a little by using an ‘or’ instead of ‘else if’… saves duplicating your 3 ‘with’ blocks twice.

IF

mode is movie or home
AND
Time Happens daily at 45 minutes to sunset

OR

mode changes away from away
AND
Time is after 45 minutes to sunset

THEN

With x

With y

With z


#4

How do I change it from an Else IF to an OR?


#5

It more about adding the new condition blocks at the top, you can’t convert the ELSE IF… that whole section just needs to be deleted as it’s duplicating stuff anyway.

You can change an AND to an OR by clicking on the AND.


#6

OK, thanks so much! I will try that.


#7

If you’re stuck I can knock up an example piston for you to import but I’m on mobile right now so won’t be straight away.


#8

Thanks! I will see how this goes tonight and tomorrow to see if it fires ok. I am really liking WebCore though. Much easier than CoRE to program. Learning a lot also!


#9

How does this look? Not sure if I need the async around the first while or around the whole IF? I think it just needs to go at the top with the IF.


#10

Looks good.


#11

Should I take out the async setting after the THEN as I have it at the top which would incorporate everything below it?


#12

The async applies to each block, having one at the top has no effect on other blocks further down… it won’t make a difference but if you want to remove an async, remove the top one.


#13

Someone correct me if I’m wrong, but none of the asyncs would be necessary if complex ifs were used. Insert a second else if [else if time happens daily at 8pm with bulb4 set level to 20%] just ahead of [else if time happens daily at 11pm]. I think it would also be easier to read and/or set other things to happen at 8pm.


#14

Many ways to skin a cat… could also be done with ‘time happens at’ / more modes / seperate pistons etc… but if it works it works :smile:


#15

image


#16

See piston at the top. That is what I was doing originally but the piston was getting stuck on the “Wait for 8:00 pm” in the first While block. So async works there. However, it was also suggested to slimline the piston so as not to have duplicate areas. So I rewrote it. It was a good learning experience!:wink: But what I am trying to understand is where to use the async. If it is at the top with the IF then wouldn’t it incorporate all the blocks within this IF statement?


#17

The Async incorporates the outside block it is in, but not further blocks within that block (I know, confusing).

Async IF A
With x
wait 10 minutes
with y
turn on

The “with y” will have to wait for the wait 10 minutes to pass, the Async is doing nothing

IF A
Async With x
wait 10 minutes
with y
turn on

The “with y” will fire at the same time as the with x, and wont have to wait for the “wait” to complete.

IF A
With x
wait 10 minutes
with y
turn on

IF B
With z
turn on

The “IF B” will have to wait for the “IF A” block to complete (so 10 minutes)

Async IF A
With x
wait 10 minutes
with y
turn on

IF B
With z
turn on

The “IF B” will fire at the same time as the “IF A” and wont have to wait for the “IF A” to complete. The “with y” will still have to wait for the “with x” to complete before firing.

Async IF A
Async With x
wait 10 minutes
with y
turn on

IF B
With z
turn on

With x y and z will all fire at the same time


#18

OK, clear as mud! No just kidding…I think I can see the differences. Thanks for the explanation.


#19

Apologies if I wasn’t clear, but I was suggesting to do away with the “wait” altogether, replacing it with a “happens daily at 8pm” further down as you had for the 11pm actions. As Robin said, many ways and it doesn’t matter how if it works, especially if the goal was to learn async behavior.


#20

Yes, I probably could have done that also. Interesting! Anyways, seemed to work tonight.