Ikea Button Trigger Smart Devices Off


#1

1) Give a description of the problem
Hi, I need some help with the design of my Piston. Used to program years back but lost touch.
I am currently new to WebCore, having used Smart Things for my home automation but not able to find full flexibility. So i am slowly mirgrating my automations into WebCore.

I am trying to automate my Work Office Room at home with range of Smart Devices: Smart Light, Motion Sensor, Ikea Dimmer Button.

As i am doing this step by step, my Piston is trying to automatically switch off my Light, Fan, Air Con based on the given If Conditions depending on the timing.

I have a Ikea Dimmer Button, where there is a Top and Bottom button. I would like to use this as a trigger to indicate that i am leaving the room(Off Button Push) and presently in the room(On Button Push) so as not to trigger any automations by to automatically off the lights while im in the room or watching tv in bed.

2) What is the expected behaviour?
So when my push the Off Button, and my Door is closed and No motion is detected. I would want to trigger Off sequence to switch off my light and fan.

there are various conditions to specifically switch off a variety of devices based on the timing.

3) What is happening/not happening?
(PUT YOUR INFO HERE)

Currently the Pistion is not triggering my actions when i initiate the button press and leave the room.

**4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I’ve only had a quick look at the first few lines of your piston, however, I think the problem is that you are "and"ing multiple instantaneous events. So, unless the motion changes to inactive at exactly the same time as you press the button, the condition will not be true.

I’m also not sure how webcore handles the stays event when combined with other events, I suspect again it would only work if all events happened simultaneously.

I’d try to design around only having one event in your if statements. Its fine to use “is” as well, e.g
if button pressed and motion is inactive
This will trigger the test when the button is pressed and then check the current status of motion. Changes to motion would not trigger the piston.


#3

The problem you have is that you are using more than one trigger condition in an AND grouping. For example, a motion changes to inactive comparison can only be true if the piston is currently processing the motion inactive event, and a button gets pushed comparison can only be true if the piston is currently processing the button pushed event. So only one of the two can possibly be true in any one instance of the piston.

The contact stays closed condition is a little more complicated. It is classed as a trigger, meaning the piston will default to subscribing to the device attribute it is considering, but it actually evaluates as contact is closed. The gotcha there is that a stays condition always returns false when the piston gets to it. The way it works is by setting a wake up timer for the duration of the ‘stay’ and then having a new instance of the piston fire that behaves as if it has returned true (unless the contact is opened in the meantime).

The problem the stays will cause you is that in order for motion changes to inactive to be able to return true, that statement also needs to be evaluated when the motion changes to active so it knows there has been a change. So you always have to be careful where you place your triggers to make sure they can be reached when the event they are interested in happens. If you nest them, or don’t have them first in an OR or AND group, then they might not be evaluated.

I haven’t looked too closely, but I suspect you need to work on the basis that it is your button press that should trigger the piston and you should consider what the other conditions are at that point. That might involve testing if the contact has already been open for a minute, for example.


#4

Thanks, I have reviewed and re-wrote my code and have changed them accordingly.

So instead of depending on the Push event button to set off my condition. What i have done instead is modify my code, where i trigger my light to turn on when the door is open. But set the Dimmer level to 80%.(This is if i enter the room momentarily for 1min).

If i intend to stay in the room longer, i increase the brightness to 100%.

So I have a condition now, when there is no motion in the room and the light brightness is less 100%. It will turn off the lights and fan. And if brightness is 100% then it indicates i am present in room and does not trigger the light off action.(Could have done using motion, but i notice at times if i sit till the motion sensor does not pick up motion easily)

I have used my Ikea Button now instead to Toggle my Movie Scene instead.