Entrance hallway lighting - optimize piston(s)


#1

1) Give a description of the problem
Hi Guys,

Here goes a long one, thanks in advance to anyone who will take the time to read through and also help with some advice.

Setup: Smartthings hub, Ikea tradfri light bulbs (named Dimmer1 and Dimmer2), Xiaomi motion sensor, xiaomi open/close (contact) sensor, Ikea tradfri button (2-button dimmer I/0).

I would like to create an appropriate piston for my entrance hallway lighting. I want the light on the hallway to act differently based on the time of the day as it follows:

  1. between 7:15 am and 8:15 am, if motion is detected on the hallway - the two light bulbs I will turn on at 100% brightness, then if there is no movement for 20 seconds, the the lights turn off (yes… I know… 20 seconds not ideal, but I have ‘hard-hacked’ the Xiaomi motion sensor to report state every 5 seconds instead of 60 seconds, and that works just fine). *** If anytime the entrance door is opened then the lights will turn/stay on. When the door is closed, if there is motion on the hallway (someone is still inside) the lights stay on for 1 minute and then turn off if there is no motion for 20 seconds; if when the door is closed there is no motion on the hallway (everyone left the house) then the light will turn off if there is no motion for 20 seconds.

  2. between 8:15 am and 6 pm the lights are not triggered by motion anymore, and only the actions described at above point 1 after the three star (*) signs will take place.

  3. between 6 pm and 8 pm same as point 1 above

  4. between 8 pm and 7:15 am, same as point 1 above, but brightness for motion is only 10%, and goes to 100% only if the door gets opened.

  5. If I press the ‘I’ button on the switch at anytime, the lights will turn/stay on until I press the ‘0’ button on the switch.

I have managed to set up the above, but the problem is that I used 4 different pistons for the 4 times of the day described above (similar to the one in the green snapshot below) and one piston for point 5 above which is set to turn on lights and pause all pistons when I press ‘I’ and resume all pistons when I press ‘0’. Thus, I see a lot of ‘waiting at the semaphore’ events within the pistons, and also all the pistons get executed together constantly throughout the day, even outside their configured times. For example if I walk to the hallway at 2 pm, the lights will not turn on (as per piston number 2 above), however the other 3 pistons (1,3,4) will show up as executed at 2 pm as well.

2) What is the expected behaviour?

Have maybe only one piston configured to do the above. or a better way to set up all pistons so that they do not get executed outside their defined times generating ‘waiting at a semaphore’ events and probably delays as well.

3) What is happening/not happening?
The config seems clustered, all pistons get executed constantly when motion is detected, ‘waiting at a semaphore’ events are generated, delays experienced between motion and lights on.

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

Any advice is much appreciated.


#2

flip lines 18 and 20. you want the trigger to come first.

remove the wait 1 minute at line 46


#3

Hmm… let me try that… do you mean that if I flip 18 an 20 the piston will not execute outside 7:15 - 8:15?


#4

correct

motion sensor changes to blah blah <—— trigger is better placed first (the yellow lightening bolt in the far left)
and
time is between blah and blah


#5

On the topic of organization…group the conditions that have the same actions together into the same If statement and separate them with “or”

nest some of your statements that have some similar conditions but others that are different

dont use 5 separate pistons for this. you can consolidate to one


#6

i felt like problem solving so i took a stab at a unified piston to do this. notice how conditions and statements are nested based on how you described it. i tried to minimize triggers, and to group all actions under said triggers, instead of reusing the triggers. i used restrictions for times and variables to make it easier to set up. just replace with your own devices.

if statement #4 might not work correctly, but its a start


#7

WOW! Thank you @steinauf , I have to wrap my head around it first, then will try to set it up in my webcore, hope this will work as expected.

Thank you for taking the time! much appreciated!

In the meantime I have configured the following piston myself (and cancelled the first 4 I had) - it is much more basic than yours (my lack of experience can be seen :stuck_out_tongue: ), but seems to do the trick (however I still did not manage to add the switch as well) - let me test your suggestion as well and if it serves the purpose then I will keep using it. Thank you again!


#8

Hi again - looking over your proposal I do understand now that the ‘switch’ thing will not work… it is not an on/off (state) switch. But a switch with two buttons (https://www.ikea.com/gb/en/p/tradfri-wireless-dimmer-white-00468432/ ).

I can assign a function to each button and the function will execute on button push, however the button push will not ‘record’ a state (like on or off). So basically there is no way to configure the piston as defined by you on line 48, as the switch will never say that it is on or off, it only generates things like: ‘top button pushed’, ‘bottom button held’, etc.

Do you see any way to work around this?

In the meantime I will try configuring the piston suggested by you while excluding any switch-related lines and conditions


#9

easily. Option #1 in this thread. Create a boolean variable and assign true to an I (on) press and false to an O (off) press. Then replace the switch in the piston with the boolean


#10

and as for the 4th If statement being troublesome, this thread is relevant.