Light on with contact sensor, off quickly unless motion


#1

1) Give a description of the problem
First thanks to whomever I got the orginal piston from in the past. It’s great!
I copied one of my working pistons and the copied version is not working. The lights turn on, but never turn off.

2) What is the expected behaviour?
If the door is opened, but there is no motion, the light will shutoff when the door is closed. If there is motion the light will turn off after two minutes of no motion.

3) What is happening/not happening?
The lights turn on, but never turnoff.

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

This piston does not work.

This piston does work.

5) Attach logs after turning logging level to Full
3/5/2021, 8:48:42 PM +129ms
+4ms ╔Received event [Basement Door Contact].contact = closed with a delay of 42ms,canQueue: true, calledMyself: false
+26ms ║RunTime initialize > 25 LockT > 2ms > rtDT > 5ms > pistonT > 4ms (first state access 18 6 19)
+30ms ║Runtime (11474 bytes) successfully initialized in 5ms (v0.3.113.20210209_HE)
+32ms ║╔Execution stage started
+41ms ║║Comparison (enum) off is (string) off = true (1ms)
+43ms ║║Comparison (enum) off is (string) off = true (1ms)
+44ms ║║Condition #6 evaluated true (8ms)
+53ms ║║Condition #5 evaluated false (7ms)
+58ms ║║Comparison (enum) closed changes_to (string) open = false (1ms)
+60ms ║║Condition #50 evaluated false (6ms)
+62ms ║║Condition group #49 evaluated false (state did not change) (16ms)
+63ms ║║Condition group #1 evaluated false (state did not change) (29ms)
+73ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
+75ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
+77ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
+79ms ║║Adding a timed trigger schedule for condition 12
+81ms ║║Cancelling condition #12’s schedules…
+82ms ║║Condition #12 evaluated false (16ms)
+83ms ║║Condition group #53 evaluated false (state did not change) (18ms)
+89ms ║║Comparison (enum) closed stays (string) closed = true (1ms)
+91ms ║║Adding a timed trigger schedule for condition 52
+94ms ║║Condition #52 evaluated false (9ms)
+95ms ║║Condition group #55 evaluated false (state did not change) (10ms)
+96ms ║║Condition group #8 evaluated false (state did not change) (30ms)
+103ms ║║Condition #48 evaluated false (5ms)
+104ms ║║Condition group #46 evaluated false (state did not change) (7ms)
+109ms ║╚Execution stage complete. (77ms)
+125ms ║Setting up scheduled job for Fri, Mar 5 2021 @ 8:48:47 PM CST (in 5s),with 1 more job pending
+127ms ╚Event processed successfully (124ms)
3/5/2021, 8:48:42 PM +169ms
+3ms ╔Received event [Basement Door Contact].contact = open with a delay of 33ms,canQueue: true, calledMyself: false
+5ms ╚Event queued (4ms)


#2

@one4spl Just found your original post for this piston. Love the piston, thanks! Would you mind looking at the one above for ideas on why it’s not working?


#3

So I think this is abusing stays…

Specifically, you need the code to ‘execute’ or ‘run over’ every stays command or else it it will miss events for tracking the stays.

see: (IT IS IMPORTANT section)


#4

Thanks for that info Eric! I’m not adapt enough at writing pistons to rewrite it using that knowledge. Maybe someone else has an idea on how to achieve the quick turn off when just the contact is opened and there’s no motion. :slight_smile:


#5

I copied a different piston to automate some other lights and that piston isn’t working correctly either. It’s not using Stays. Is there possibly an issue with copying pistons? I’m using Hubitat.


#6

Just thought I would pass along that the piston is now working without any changes. While I was working to build it out in Rule Machine I noticed it was showing the door contact as open when the door was closed. Turns out the contact was flaky, when I closed the door the contact would close and then immediately change to open again even though the door was closed. I reset the contact to correct this issue and now the piston works.