Return cabinet lighting to previous state


#1

1) Give a description of the problem
Cant figure out how to stop a light behavior after turning on conditionally.

2) What is the expected behaviour?
At the end of the script I have added instruction to make my leds flash like police when a contact sensor opens when the alarm is set to on

3) What is happening/not happening?
everything is working I just don’t know how to make them return to the previous state.

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

5) Attach logs after turning logging level to Full
4/2/2020, 8:13:17 PM +685ms
+1ms ╔Received event [Kitchen Motion].motion = inactive with a delay of 115ms
+66ms ║RunTime Analysis CS > 15ms > PS > 29ms > PE > 21ms > CE
+68ms ║Runtime (44831 bytes) successfully initialized in 29ms (v0.3.110.20191009) (66ms)
+69ms ║╔Execution stage started
+106ms ║║Comparison (time) 72797759 is_between (time) 79200000 … (time) 1585829520000 = false (7ms)
+107ms ║║Condition #2 evaluated false (34ms)
+108ms ║║Condition group #1 evaluated false (state did not change) (35ms)
+121ms ║║Comparison (enum) off is (string) on = false (1ms)
+122ms ║║Condition #20 evaluated false (8ms)
+123ms ║║Condition group #19 evaluated false (state did not change) (10ms)
+125ms ║╚Execution stage complete. (56ms)
+127ms ║Setting up scheduled job for Thu, Apr 2 2020 @ 10:00:00 PM CDT (in 6402.189s), with 1 more job pending
+136ms ╚Event processed successfully (136ms)
4/2/2020, 8:12:32 PM +538ms
+1ms ╔Received event [Kitchen Motion].motion = active with a delay of 224ms
+62ms ║RunTime Analysis CS > 15ms > PS > 23ms > PE > 23ms > CE
+64ms ║Runtime (44829 bytes) successfully initialized in 23ms (v0.3.110.20191009) (62ms)
+65ms ║╔Execution stage started
+103ms ║║Comparison (time) 72752608 is_between (time) 79200000 … (time) 1585829520000 = false (8ms)
+105ms ║║Condition #2 evaluated false (34ms)
+106ms ║║Condition group #1 evaluated false (state did not change) (36ms)
+119ms ║║Comparison (enum) off is (string) on = false (1ms)
+121ms ║║Condition #20 evaluated false (9ms)
+122ms ║║Condition group #19 evaluated false (state did not change) (11ms)
+124ms ║╚Execution stage complete. (59ms)
+126ms ║Setting up scheduled job for Thu, Apr 2 2020 @ 10:00:00 PM CDT (in 6447.337s), with 1 more job pending
+137ms ╚Event processed successfully (137ms)
4/2/2020, 8:12:27 PM +326ms
+1ms ╔Received event [Home].execute = 144.160.96.229 with a delay of 93ms
+85ms ║RunTime Analysis CS > 21ms > PS > 40ms > PE > 24ms > CE
+87ms ║Runtime (44827 bytes) successfully initialized in 40ms (v0.3.110.20191009) (86ms)
+88ms ║╔Execution stage started
+143ms ║║Comparison (time) 72747418 is_between (time) 79200000 … (time) 1585829520000 = false (7ms)
+144ms ║║Condition #2 evaluated false (52ms)
+145ms ║║Condition group #1 evaluated false (state did not change) (53ms)
+157ms ║║Comparison (enum) off is (string) on = false (1ms)
+158ms ║║Condition #20 evaluated false (7ms)
+159ms ║║Condition group #19 evaluated false (state did not change) (9ms)
+162ms ║╚Execution stage complete. (73ms)
+163ms ║Setting up scheduled job for Thu, Apr 2 2020 @ 10:00:00 PM CDT (in 6452.511s), with 1 more job pending
+176ms ╚Event processed successfully (176ms)
4/2/2020, 8:12:25 PM +97ms
+2ms ╔Received event [Kitchen Motion].motion = inactive with a delay of 156ms
+111ms ║RunTime Analysis CS > 37ms > PS > 51ms > PE > 23ms > CE
+114ms ║Runtime (44832 bytes) successfully initialized in 51ms (v0.3.110.20191009) (111ms)
+114ms ║╔Execution stage started
+168ms ║║Comparison (time) 72745215 is_between (time) 79200000 … (time) 1585829520000 = false (7ms)
+169ms ║║Condition #2 evaluated false (51ms)
+170ms ║║Condition group #1 evaluated false (state did not change) (52ms)
+183ms ║║Comparison (enum) off is (string) on = false (1ms)
+184ms ║║Condition #20 evaluated false (9ms)
+185ms ║║Condition group #19 evaluated false (state did not change) (10ms)
+187ms ║╚Execution stage complete. (73ms)
+189ms ║Setting up scheduled job for Thu, Apr 2 2020 @ 10:00:00 PM CDT (in 6454.715s), with 1 more job pending
+200ms ╚Event processed successfully (200ms)
4/2/2020, 8:12:14 PM +440ms
+0ms ╔Received event [Home].test = 1585876334439 with a delay of 0ms


#2

You need to decide on an event, and then create a trigger based on that event that will reset the light.


#3

The event would be disarming the alarm.
If alarm changes to off then… at this point i want it to return to the previous state, either mothin activated or deepfading depending on time of day.

When the alarm is armed and a door opens setting off the alarm, the lights change to police. When the alarm gets turned off i want it to return to previos state.


#4

I would program that logic in a different piston… Ideally, the piston that is acting based on the Alarm.

Something like:

IF Alarm changes to disarm             <-- Trigger
Then
    IF time is between sunrise & 10pm  <-- Condition
    Then
        With Light: deepfade()
    ELSE
        With Light: Turn off
    END IF
END IF

#5

So is it better to keep pistons small/simple vs packing everything into one complex piston?


#6

I am a huge fan of one trigger (or less) per piston…
(My piston may be giant, with many complex conditions beneath the trigger, but I only want one thing to actually activate the piston)

The basic concept is, each trigger will have to process every line of code at each and every event. The less triggers per piston, the more streamlined SmartHome you will have.


#7

Makes sense and thanks for taking the time.