Having issue with motion sensor trigger


#1

My motion sensors seem to have stopped triggering my lights tonight. The piston is very basic and simply turns on the light if the motion sensor changes to active:

I captured the following from the log:

+1ms ╔Received event [Downstairs Bathroom Motion].motion = active with a delay of 497ms
+104ms ║RunTime Analysis CS > 17ms > PS > 54ms > PE > 33ms > CE
+107ms ║Runtime (37863 bytes) successfully initialized in 54ms (v0.3.109.20181207) (104ms)
+108ms ║╔Execution stage started
+120ms ║║Comparison (enum) active changes_to (string) active = false (1ms)
+122ms ║║Cancelling condition #2’s schedules…
+124ms ║║Condition #2 evaluated false (9ms)
+125ms ║║Cancelling condition #1’s schedules…
+126ms ║║Condition group #1 evaluated false (state changed) (13ms)
+129ms ║║Cancelling statement #3’s schedules…
+134ms ║║Executed virtual command wait (0ms)
+135ms ║║Requesting a wake up for Sun, Feb 10 2019 @ 8:07:50 PM EST (in 300.0s)
+141ms ║╚Execution stage complete. (34ms)
+143ms ║Setting up scheduled job for Sun, Feb 10 2019 @ 8:07:50 PM EST (in 299.994s)
+153ms ╚Event processed successfully (153ms)

It looks like although the sensor is changing to active the comparison is returning false anyways and fails to turn on the light.

I have several routines like this and they have all been working just fine for a couple of months.

I also seem to be having issues with events not triggering the pistons. For example, I can see the light flash on a motion sensor and see the event in the SmartThings app (classic), but I don’t see any entry in the WebCore log where the event should have triggered a piston.

Any thoughts?


#2

The log here shows that it executed the ELSE block. I usually avoid using ELSE blocks on motion sensors, since they fire so often, you will find that your ELSE commands will run when they shouldn’t.

The way I usually structure a piston for a motion sensor is something like this:

IF Motion Sensor changes to active
    Then Turn on light
END IF

IF Motion Sensor stays inactive for 5 minutes
    Then Turn off light
END IF

My sample above has two independent triggers, but the turn off command will restart the 5 minute timer each time it sees more activity.


#3

I continue to have trouble understanding WAIT statements, especially when used in conjunction with motion sensors. I usually just add a Task Cancellation Policy of Never to make sure the code after the wait gets executed. I am not sure if that is the best approach.


#4

Who’s to say what is “wrong” in webCoRE… If it works for you, then it works for you. I just wanted you to know that the coding logic is quite different if you start using TCP set to Never as default.


As far as Motion Sensors goes, it really depends on the device, company, and Device Handler…
One fairly common pattern is many devices send current status on a repeating timer… Such as:

Active
Active
Active
Active
Active
Inactive
Inactive
Inactive
Inactive
etc…

The IF statement is only true on the first active…
but
the piston runs top to bottom at each signal.
(Meaning your ELSE block executes at each of the false IFs)

Personally, I try to avoid coding with this logic, so I try to keep ELSE out of Motion Sensor statements.

Your mileage may vary.


#5

This explains why I have problems with IF-THEN-ELSE statements involving motion sensors and WAIT.


#6

For what it’s worth, about 99% of my statements do not use ELSE.


#7

That makes sense. I’ve learned a bit more about how the event subscriptions work since I wrote those and will modify them as you suggested.

However, I still seem to have some “missing” events sometimes. Has anyone else seen that happen?

BTW, everything seems to be working again this morning.