Just want off to start off by saying iv just installed webcore 2 days ago, so Im not the best with it. Iv setup a piston to auto turn on my bedroom light if mode is set to home, and motion is detected in the room. Im running into a problem though were if motion is already detect when mode goes from away to home, then it wont turn the light on until a new motion activation. How would I go about fixing this
Also post on the webCoRE forum
Apologies if this is teaching granny to suck eggs …
When working with webCoRE you have to ask yourself ‘what will cause this piston to execute?’. Something has to happen to make it run. The bottom line is that a piston is a SmartApp, and so it will be subscribing to device or location events, or using timer events.
Something webCoRE doesn’t make immediately clear is the difference between ‘conditions’ and ‘triggers’. If you are writing an if statement and use ‘motionsensor motion is active’, that is a condition. If you write ‘motionsensor changes to active’, that is a trigger. The key difference is that, by default, webCoRE will only look at the triggers to see what events it needs to subscribe to. If it doesn’t find any it will try to be helpful and subscribe to device events used in conditions.
So if you have a webCoRE ‘if block’ that says:
IF motionsensor motion changes to active AND location mode is home THEN …
then webCoRE will see a trigger and only run the piston when the motion sensor changes state (it runs it regardless of what it changes to and from). Trigger conditions can only evaluate to true when they are used to trigger the piston so only one is ever true. Triggers like ‘changes to’ are also only true for a relatively short period of time (say ten seconds, but I don’t know the exact time) so can change value while your piston is running (but that’s another story …)
If the ‘if block’ is instead:
IF motionsensor motion is active AND location mode is home THEN …
and there aren’t any other triggers anywhere in the piston, then webCoRE will see that you are interested in the motion sensor events and changes in location mode and will subscribe to both. So the piston will run whenever the motion sensor changes state or the location mode changes.
Hopefully some of that might help.