Motion sensor light control night and day


#1

1) Give a description of the problem
(I’m new to webcore and am just having probably stupid issues because I’m not versed enough)

2) What is the expected behaviour?
(I would like to have a piston that when location is set to home mode, and the motion changes to active, it will set the light level/brightness to 98% and when the motion sensor doesn’t detect motion for 1 minute, location is home mode, and light brightness is 98% or less, the light will turn off)

3) What is happening/not happening?
(I tried building a piston with both night and home variables, as at night I’d like the light to be set to 1% and turn off based on the same parameters as the description above but the proper values changed. In my current piston, the light turns off, but will not turn back on immediately when motion is resensed and doesn’t include the night mode variation)

**4) Post a Green Snapshot of the piston

5) Attach logs after turning logging level to Full
10/1/2020, 3:46:03 AM +195ms
+2ms ╔Received event [Motion Sensor].motion = inactive with a delay of 53ms
+44ms ║RunTime Analysis CS > 19ms > PS > 8ms > PE > 17ms > CE
+46ms ║Runtime (38986 bytes) successfully initialized in 8ms (v0.3.110.20191009) (44ms)
+47ms ║╔Execution stage started
+53ms ║║Comparison (string) :c8aad1618f993828f9240fdeb150ff17: is (string) :c8aad1618f993828f9240fdeb150ff17: = true (1ms)
+54ms ║║Condition #2 evaluated true (4ms)
+58ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+59ms ║║Cancelling condition #3’s schedules…
+60ms ║║Condition #3 evaluated false (4ms)
+61ms ║║Cancelling condition #1’s schedules…
+61ms ║║Condition group #1 evaluated false (state changed) (11ms)
+72ms ║║Comparison (integer) 100 is_less_than_or_equal_to (integer) 98 = false (1ms)
+73ms ║║Condition #6 evaluated false (10ms)
+74ms ║║Condition group #4 evaluated false (state did not change) (11ms)
+76ms ║╚Execution stage complete. (30ms)
+77ms ╚Event processed successfully (77ms)
10/1/2020, 3:45:43 AM +323ms
+1ms ╔Received event [Motion Sensor].motion = active with a delay of 44ms
+32ms ║RunTime Analysis CS > 13ms > PS > 4ms > PE > 15ms > CE
+34ms ║Runtime (38991 bytes) successfully initialized in 4ms (v0.3.110.20191009) (33ms)
+35ms ║╔Execution stage started
+42ms ║║Comparison (string) :c8aad1618f993828f9240fdeb150ff17: is (string) :c8aad1618f993828f9240fdeb150ff17: = true (1ms)
+43ms ║║Condition #2 evaluated true (4ms)
+47ms ║║Comparison (enum) active changes_to (string) active = true (0ms)
+48ms ║║Cancelling condition #3’s schedules…
+49ms ║║Condition #3 evaluated true (5ms)
+50ms ║║Cancelling condition #1’s schedules…
+51ms ║║Condition group #1 evaluated true (state changed) (11ms)
+53ms ║║Cancelling statement #10’s schedules…
+67ms ║║Executed physical command [Bathroom Light].setLevel([98]) (10ms)
+68ms ║║Executed [Bathroom Light].setLevel (12ms)
+70ms ║╚Execution stage complete. (35ms)
+71ms ╚Event processed successfully (71ms)
10/1/2020, 3:43:51 AM +305ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+195ms ║Subscribing to Motion Sensor.motion…
+335ms ╚Piston successfully started (334ms)


#2

I am thinking basing it on the motion sensor… Maybe something like this:

IF Sensor's motion changes to active         <-- Trigger
Then
    IF location mode is Home                 <-- Condition
    Then
        Set bulb's level to 98%
    END IF
    IF location mode is Night                <-- Condition
    Then
        Set bulb's level to 1%
    END IF
END IF

IF Sensor's motion stays inactive for 2 min  <-- Trigger
Then
    Turn off bulb
END IF

This is two IFs… with the top IF containing two nested IFs inside.

Technically, you can add extra conditions to the last IF in the same way, but I would not want the bulb to get stuck on while you were on vacation (for example).