Lights Off When Below x Level for y Time


#1

1) Give a description of the problem
Trying to get lights to turn off automatically if they stay below a certain level for a certain amount of time. Other people in my house inadvertently dim the lights very low instead of just turning them off, so I need a piston to turn them off and reset their level to 100% when that happens.

2) What is the expected behaviour?
Light switch turns off and level is reset to 100% without turning the lights back on. If the switch is turned off or the level rises above the threshold during the wait period, the piston should reset.

3) What is happening/not happening?
Piston is turning the light off even though the level is not below the defined level (10%).

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

5) Attach logs after turning logging level to Full

8/24/2020, 3:56:45 PM +352ms
+2ms â•”Received event [Island Lights].switch = off with a delay of 75ms
+298ms â•‘RunTime Analysis CS > 19ms > PS > 242ms > PE > 37ms > CE
+301ms â•‘Runtime (43344 bytes) successfully initialized in 242ms (v0.3.110.20191009) (299ms)
+302ms â•‘â•”Execution stage started
+368ms â•‘â•‘Comparison (integer) 100 is_less_than_or_equal_to (integer) 10 = false (1ms)
+370ms â•‘â•‘Comparison (integer) 79 is_less_than_or_equal_to (integer) 10 = false (2ms)
+372ms â•‘â•‘Comparison (integer) 100 is_less_than_or_equal_to (integer) 10 = false (1ms)
+374ms â•‘â•‘Comparison (integer) 64 is_less_than_or_equal_to (integer) 10 = false (1ms)
+376ms â•‘â•‘Comparison (integer) 81 is_less_than_or_equal_to (integer) 10 = false (1ms)
+378ms â•‘â•‘Comparison (integer) 8 is_less_than_or_equal_to (integer) 10 = true (1ms)
+381ms â•‘â•‘Condition #11 evaluated true (75ms)
+427ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+429ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+432ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+434ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+436ms â•‘â•‘Comparison (enum) off is (string) on = false (2ms)
+438ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+440ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+442ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+444ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+447ms â•‘â•‘Cancelling condition #12's schedules...
+448ms â•‘â•‘Condition #12 evaluated false (66ms)
+449ms â•‘â•‘Cancelling condition #1's schedules...
+450ms â•‘â•‘Condition group #1 evaluated false (state changed) (144ms)
+452ms ║╚Execution stage complete. (150ms)
+453ms ╚Event processed successfully (452ms)
8/24/2020, 3:56:39 PM +160ms
+0ms â•”Received event [187 Montgomery Avenue].time = 1598299000762 with a delay of -1603ms
+176ms â•‘RunTime Analysis CS > 23ms > PS > 117ms > PE > 37ms > CE
+179ms â•‘Runtime (43363 bytes) successfully initialized in 117ms (v0.3.110.20191009) (178ms)
+180ms â•‘â•”Execution stage started
+201ms â•‘â•‘Skipped execution of physical command [Island Lights].setLevel([100]) because it would make no change to the device. (8ms)
+201ms â•‘â•‘Executed [Island Lights].setLevel (10ms)
+516ms â•‘â•‘Executed physical command [Island Lights].off() (313ms)
+517ms â•‘â•‘Executed [Island Lights].off (313ms)
+522ms â•‘â•‘Calculating (string) Webcore: + (string) Island Lights >> (string) Webcore: Island Lights
+525ms â•‘â•‘Calculating (string) Webcore: Island Lights + (string) Turned Off as Below 10% >> (string) Webcore: Island Lights Turned Off as Below 10%
+607ms â•‘â•‘Executed virtual command [Island Lights].sendPushNotification (78ms)
+609ms ║╚Execution stage complete. (429ms)
+610ms ╚Event processed successfully (610ms)
8/24/2020, 3:56:10 PM +434ms
+1ms â•”Received event [Island Lights].switch = on with a delay of 89ms
+181ms â•‘RunTime Analysis CS > 21ms > PS > 109ms > PE > 51ms > CE
+184ms â•‘Runtime (43349 bytes) successfully initialized in 109ms (v0.3.110.20191009) (182ms)
+185ms â•‘â•”Execution stage started
+252ms â•‘â•‘Comparison (integer) 100 is_less_than_or_equal_to (integer) 10 = false (1ms)
+254ms â•‘â•‘Comparison (integer) 79 is_less_than_or_equal_to (integer) 10 = false (1ms)
+256ms â•‘â•‘Comparison (integer) 100 is_less_than_or_equal_to (integer) 10 = false (2ms)
+258ms â•‘â•‘Comparison (integer) 64 is_less_than_or_equal_to (integer) 10 = false (2ms)
+260ms â•‘â•‘Comparison (integer) 81 is_less_than_or_equal_to (integer) 10 = false (2ms)
+262ms â•‘â•‘Comparison (integer) 8 is_less_than_or_equal_to (integer) 10 = true (2ms)
+264ms â•‘â•‘Condition #11 evaluated true (75ms)
+311ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+313ms â•‘â•‘Comparison (enum) off is (string) on = false (1ms)
+316ms â•‘â•‘Comparison (enum) on is (string) on = true (1ms)
+318ms â•‘â•‘Cancelling condition #12's schedules...
+319ms â•‘â•‘Condition #12 evaluated true (54ms)
+320ms â•‘â•‘Cancelling condition #1's schedules...
+321ms â•‘â•‘Condition group #1 evaluated true (state changed) (132ms)
+323ms â•‘â•‘Cancelling statement #2's schedules...
+326ms â•‘â•‘Executed virtual command [Island Lights].wait (0ms)
+327ms â•‘â•‘Requesting a wake up for Mon, Aug 24 2020 @ 3:56:40 PM EDT (in 30.0s)
+331ms ║╚Execution stage complete. (146ms)
+333ms â•‘Setting up scheduled job for Mon, Aug 24 2020 @ 3:56:40 PM EDT (in 29.996s)
+339ms ╚Event processed successfully (339ms)
8/24/2020, 3:55:52 PM +303ms
+1ms â•”Starting piston... (v0.3.110.20191009)
+339ms â•‘â•”Subscribing to devices...
+390ms â•‘â•‘Subscribing to Basement Steps.level...
+401ms â•‘â•‘Subscribing to Family Room Lights.level...
+413ms â•‘â•‘Subscribing to Island Lights.level...
+424ms â•‘â•‘Subscribing to Kitchen Lights.level...
+435ms â•‘â•‘Subscribing to Layla's Lights.level...
+447ms â•‘â•‘Subscribing to Master Bedroom Lights.level...
+458ms â•‘â•‘Subscribing to Ping Pong Lights.level...
+469ms â•‘â•‘Subscribing to Playroom Lights.level...
+485ms â•‘â•‘Subscribing to Rowing Machine Lights.level...
+498ms â•‘â•‘Subscribing to Basement Steps.switch...
+510ms â•‘â•‘Subscribing to Family Room Lights.switch...
+520ms â•‘â•‘Subscribing to Island Lights.switch...
+530ms â•‘â•‘Subscribing to Kitchen Lights.switch...
+607ms â•‘â•‘Subscribing to Layla's Lights.switch...
+618ms â•‘â•‘Subscribing to Master Bedroom Lights.switch...
+629ms â•‘â•‘Subscribing to Ping Pong Lights.switch...
+638ms â•‘â•‘Subscribing to Playroom Lights.switch...
+648ms â•‘â•‘Subscribing to Rowing Machine Lights.switch...
+800ms ║╚Finished subscribing (463ms)
+885ms â•‘Comparison (integer) 100 is_less_than_or_equal_to (integer) 10 = false (2ms)
+888ms â•‘Comparison (integer) 79 is_less_than_or_equal_to (integer) 10 = false (2ms)
+890ms â•‘Comparison (integer) 100 is_less_than_or_equal_to (integer) 10 = false (1ms)
+893ms â•‘Comparison (integer) 64 is_less_than_or_equal_to (integer) 10 = false (2ms)
+895ms â•‘Comparison (integer) 81 is_less_than_or_equal_to (integer) 10 = false (1ms)
+898ms â•‘Comparison (integer) 8 is_less_than_or_equal_to (integer) 10 = true (2ms)
+954ms â•‘Comparison (enum) off is (string) on = false (2ms)
+957ms â•‘Comparison (enum) off is (string) on = false (1ms)
+959ms â•‘Comparison (enum) off is (string) on = false (1ms)
+962ms â•‘Comparison (enum) off is (string) on = false (2ms)
+964ms â•‘Comparison (enum) off is (string) on = false (1ms)
+967ms â•‘Comparison (enum) off is (string) on = false (2ms)
+969ms â•‘Comparison (enum) off is (string) on = false (1ms)
+972ms â•‘Comparison (enum) off is (string) on = false (2ms)
+974ms â•‘Comparison (enum) off is (string) on = false (1ms)
+990ms ╚Piston successfully started (990ms)

#2

I would avoid using this logic:

IF DeviceA switch changes
Then
    Change DeviceA's switch
END IF

#3

OK thanks. What would you propose as an alternative please?


#4

I have hot food in front of me… Be back in a bit


#5

No problem, thanks! Gotta eat!


#6

I am a fan of using STAY, but it works best with only a single trigger. IE:

If DimmerA's level STAYS BELOW 11% for 30 seconds
Then
   With DimmerA
      Set level to 100%
      Turn off
      Send PUSH
   END WITH
END IF

#7

OK thanks will try that. Only question is, how can I tie the switch’s state (on or off) into the piston? The switch and dimmer level seem to be independent properties, correct? I would want the whole piston to only operate if the switch is on, including cancelling the STAYS timer if the switch is turned off during the 30 seconds. Any thoughts on that?


#8

Just to clarify… If someone turns the level down to 5%, and then turns it off, you do not want the level reset, and the light turned off again?


#9

I only want the piston to reset the level and turn the switch off if the switch remains on and the level remains below 10% for the defined period. Let’s say the switch is on and level is at 100% and then someone sets the level to to 5%. Timer should then start. If during that time window the level goes back above 10% or the switch is turned off, the timer should cancel. So yes, what you said I guess!


#10

You can add an indented conditional check, that only happens after the 30 secs…
Perhaps a slight variation of my earlier piston:

If DimmerA's level STAYS BELOW 11% for 30 sec  <-- Trigger
Then
   IF DimmerA is on                            <-- Condition
   Then
      With DimmerA
         Set level to 100%
         Turn off
         Send PUSH
      END WITH
   END IF
END IF
  • Every level changes executes the piston
  • Every level change below 11% starts the timer
  • If DimmerA is on after the timer, then the level is reset

Note, you may have trouble in this scenario:

  • DimmerA level set to 5%
  • DimmerA is turned off ten sec later
  • DimmerA is turned on an hour later (still at 5%)

I suspect the piston will not run again until the level changes again.
(this is why I suggested resetting the level regardless if the bulb is on or not)


#11

This worked thank you! You were right about this too: “I suspect the piston will not run again until the level changes again.”; so resetting the level to 100% makes sense, yes.

I also tested it with multiple devices’ levels going below 11% during the same time window and that worked too. Thanks for your help!