My lighting piston


#1

1) Give a description of the problem
Nothing happens. I do see the piston state is set to false, not sure if that has anything to do with it. I tried enabling it in the settings, but it doesn’t change from being false. Not sure if other things I have “setup” working the way I want it to work.

2) What is the expected behaviour?
From 30 minutes before sunset to 30 minutes after sunrise my living room lights will turn on to 50% dimmer level, and my master bedroom lights will turn on once I arrive home (based off my iPhone’s location hopping onto my wifi). I then set another statement from 12:30AM to 4:30AM if no motion is detected by the living room sensor the living room light will turn off.

3) What is happening/not happening?
Nothing happens.

**4) Post a Green Snapshot of the piston!



5) Attach logs after turning logging level to Full
9/16/2019, 10:51:50 PM +845ms
+1ms ╔Received event [Philly Condo].test = 1568688710841 with a delay of 3ms
+121ms ║RunTime Analysis CS > 25ms > PS > 49ms > PE > 47ms > CE
+125ms ║Runtime (39803 bytes) successfully initialized in 49ms (v0.3.10f.20190822) (121ms)
+127ms ║╔Execution stage started
+175ms ║║Comparison (time) 82310983 is_before (time) 1568675280000 = false (8ms)
+178ms ║║Condition #2 evaluated false (41ms)
+179ms ║║Condition group #1 evaluated false (state did not change) (43ms)
+197ms ║║Comparison (time) 82311028 is_between (time) 1800000 … (time) 16200000 = false (11ms)
+200ms ║║Condition #10 evaluated false (17ms)
+201ms ║║Condition group #9 evaluated false (state did not change) (19ms)
+212ms ║╚Execution stage complete. (85ms)
+213ms ╚Event processed successfully (213ms)


#2

I’m not at home and cannot put full effort in at this time but…
Three things :
First, please enable Trace in your piston and re-post the resulting piston and the log. That will allow us to follow along in the code.
Second, I think you will have problems with the 1 millisecond presence sensor condition. With internet latency, it will be nearly impossible to isolate presence to 1 millisecond. Since webCoRE runs in the cloud, it will be difficult to capture accurate readings for almost everything in the millisecond range. That’s my experience anyway.
Third, I don’t think you need to worry about Automatic Piston State at this time. Just leave it default.

I’ll focus more on this when I get home on my computer.


#3

Everything @Pantheon says and I want to add some,

1 - When you have triggers and conditions, ALWAYS trigger first condition later.
I recommend you read this, this article helped me tremendously

2 - For now I’d say stay away from using ELSE. In my limited coding experience ELSE in webcore is behaving slightly different then ELSE in regular coding. Non-coder talking be warned LOL

3 - Instead of writing the full piston, go step by step.
First, just work on the lights turning ON, once that’s done and working as you would want, move on to turning off part/

4 - When your piston relies on presence sensor, get ready to see delays etc. Presence sensors are not 100% efficient YET. Signal is going all the way to the satellite and all:)))

5 - Even with same lights, if you have 2 different jobs, I would write 2 different pistons. you can do it in a single piston but once you have over 100 pistons and trying to trouble shoot something, mixed pistons will drive you insane.

Here is how I would write your piston:

IF Presence sensor changes to Present (trigger)
And 
IF time is between X and Y (condition)
Then 
with light bulb a set level 50
Then 
with light bulb b turn ON

If motion sensor motion stays inactive for X minutes (meaning nothing moved at all in the last x minutes)
Then 
With any light bulbs you want Turn OFF

#4

Absolutely agree with everything @ike2018 said. Especially the above. It is SO tempting to put everything into one piston. “After all, I’m just dealing with a couple of lights.” But life will be much better if you write smaller pistons that do a single task. They are easier to code and debug. Also, your chances of getting help here are greater if they are easier to debug. Long, complex pistons have their place. But short, simple ones are so much easier, even if you have to write 2 or 3 to get a simple task completed.


#5

This was a hard lesson for me:)))
the other way looked more pro - for my ego - :)))))


#6

Getting closer! Thanks for replying guys, especially @Pantheon for replying not at his computer. So took your guys advice and decided to break up (and not use else part of the statements) different rooms into separate piston’s. So for now still working on my living room lights one, and with all the other if parameters out the piston WAS working and turning on the light to the level I wanted it at. Then I added my Time parameters back in and with Trace turned on (testing now out of the hours set) and my iPhone presence it didn’t work. Is the time stuff setup correctly? At least it worked with that stuff out of it.

logs:
9/17/2019, 1:28:04 PM +136ms
+0ms ╔Received event [Philly Condo].test = 1568741284133 with a delay of 2ms
+115ms ║RunTime Analysis CS > 28ms > PS > 48ms > PE > 40ms > CE
+118ms ║Runtime (38116 bytes) successfully initialized in 48ms (v0.3.10f.20190822) (115ms)
+120ms ║╔Execution stage started
+163ms ║║Comparison (time) 48484263 is_before (time) 1568761560000 = true (8ms)
+164ms ║║Time restriction check passed
+167ms ║║Condition #7 evaluated true (39ms)
+180ms ║║Comparison (time) 48484304 is_after (time) 1568716980000 = true (9ms)
+181ms ║║Time restriction check passed
+183ms ║║Condition #8 evaluated true (16ms)
+190ms ║║Condition #9 evaluated false (5ms)
+191ms ║║Condition group #1 evaluated false (state did not change) (65ms)
+196ms ║╚Execution stage complete. (77ms)
+198ms ╚Event processed successfully (197ms)


#7

it’s not working because your conditions are tied with AND. You are telling piston to execute ONLY IF time is sunset AND sunrise simultaneously. It will never execute.
Instead use TIME IS BETWEEN or TIME IS NOT BETWEEN function.

and Use presence sensor CHANGES as first line of the IF block because that’s a trigger


#8

Great! Always thought my timing was off. So set it like this and it does work testing it. I do want it in conjunction to my iPhone and nobody else’s, so and should be and right? Does the presence setting look right? Think we’re almost (if not already) there.


#9

almost…very close…
i don’t get what that NOT is coming from…
Use the presence sensor changing as FIRST line…

IF Presence sensor changes to present
AND
IF time is Between 10 minutes to sunset and 30 minutes after sunset

#10

Also worth pointing out that the Test button does absolutely nothing with this piston. The only trigger is when Presence changes, so that is how you test this piston.


#11

Think we’re getting closer! Switched the iPhone presence and Time around, then added another condition if I’m already home. So that I wanted to be Coming Home or Currently Home, then an And for the time period. Is this a case where I’d want 2 different pistons? Didn’t see a way to set it to I had Or and then And for the time period. Thanks for the help guys you’re helping me along!


#12

So think I’m having trouble with my iPhone sensor. I’ve since deleted the 2nd part that stays present just to test and turning on and off my wifi now during the hours nothing’s happening. I’d think I’d want an and there but “testing” it you see what happens. Placing an or there the "test’ works and turns it on in the app, but like I said earlier nothings happening. Should I be doing anything different?

You guys want any logs either way?


#13

You will get many opinions on this here, but my experience is that using Presence for triggers in webcore is fraught with problems. It is very unreliable for me and I do not use it for triggers. Currently you are using the Presence Sensor as a trigger (see the orange lightening bolt next to it).

I know that not using a Presence Sensor does not help you much. I use motion sensors for such things. I do use Presence Sensors for conditions, such as if I want to know who is home (or away from home). But those conditions are not generally finite time specific. My phone is android and my wife’s is an iPhone. Both of them vary considerably in response times and can be off by several minutes. That makes it difficult to use them to turn on lights and things.


#14

Thanks for the reply. That’s probably what’s happening here (not sure how to change the Presence sensor my iPhone from being a trigger). Any suggestion on how I want to get this accomplished? I do have a presence sensor in my living room, door sensor, and smart lock (with user pin codes) as other options plus my iPhone. But I only wanted this to be used for me, not other people who visit here.


#15

Do you mean a motion sensor? If so, you can use that (and the door sensor and/or smart lock) to turn on your lights. But, of course, that will respond to anyone in that room. Sorry, but I do not see a method to reliably use your presence sensor to turn on the lights in this situation.


#16

I couldn’t agree more…

Just a quick question, is your light bulb ph hue or some other brand. Because ph hue bulbs responds to set level but some other brands need turn on command first…

You can use the presence sensor as a condition but again it may not give you satisfaction

If notion sensor change to active
And
Presence sensor is present
Then do this do that


#17

Yeah, sorry meant a motion sensor in my living room. No Phillips Hue bulbs here, just Lutron Caseta smart dimmers. I do have my Schlage Connect setup setup with RBoy Apps Lock User Management so everybody coming into the condo has a discreet pin code. Could I integrate that at all?

I was really hoping to make it user specific someway here (not based on motion). Think we ever see webcore focusing on fixing the Presence issues? I’m subscribed to this thread if you guys update me here to try again later. That was the main reason for me trying webcore.


#18

Did you try turn on the bulb first and then set level?


#19

Many of us are looking for a RELIABLE presence sensor solution. Some do not have any problems at all. Others, like myself, have great variability in the daily operation. Therefore, I cannot strictly rely on presence sensors for critical or time sensitive triggering.


#20

Same here… I usually get 15-20 seconds delay, sometimes no change in status at all.