Simplify Piston (new to this!)


#1

1) Give a description of the problem
Have designed piston, works but must be a more efficient method for duplication purposes
2) What is the expected behaviour?
Between 3 different time periods, set light percentage to a set amount and turns on

3) What is happening/not happening?
Works ok, just need it simplified so I can understand and learn better more efficient methods

**4) Post a Green Snapshot of the piston![image|45x37]

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

Fairly straight forward piston, there are ways that you could update but most would be classified as preferential rather than simplification (like setting a variable to the level integer based on time, with only one block setting the level of the bulb to the variable).

One performance suggestion would be to update the IF Time is between 21:00 and 45 minutest past sunrise line to read IF Time is NOT between 45 minutest past sunrise and 21:00. Times spanning midnight can sometimes can issues with execution.

Also general rule, I tend to put triggers at the top of any IF block, I would usually write your bottom IF block as:
IF
Motion Sensor 2’s motion stays inactive for 78 seconds (trigger)
and
White Bulb 6’s switch is on

However in this case, the condition of the bulb being on is somewhat irrelevant. If the bulb is off and the motion sensor’s inactivity is triggered, sending an off command will do nothing as the state is already off.


#3

ok, thanks for those I have changed the IF block and Trigger to your recommendations as that makes perfect sense.

I have trying to do an If statement so if time between A to B then set var perc to value

and the end of those 3 if statements for time, then have the block that finally sets light value and then turns on etc, however how do I get the if statements to work that way as when i try to do one it wants a device, not a virtual like time


#4

Something like this:


#5

I do something just like this, I set the variable at a specific times throughout the day. I use a global variable so all pistons can use the levels and color temperature. Doing so saves me from duplicating the “If time is” statements in each room’s pistons. Is that your goal?

image


#6

Essentially. By using a master piston to set a variable, it is much easier to call the variable in other pistons than have multiple pistons exectue the same trigger.