Issue with front door open piston

Hi guys,

I’ve amended this piston that I’ve found but cant get it to work correctly.

There is no Sonos output after 1 min that the contact is open.

Any ideas?

Capture

You don’t have a trigger. Try changing the first line to “Changes to Open.” This will trigger the automation to run.

Just use if contact stays open for 1 minute
And
Location is night

Thanks for your prompt replies, I added the trigger as suggested (and changed the action to flashing a light for the test) I have this piston working when I “test it”. The lights flash twice when disconnecting the door contact, and flash if i reconnect them quickly.

However if I try again 2 minutes later, it doesn’t execute. Am i missing something?
Ive double checked and the piston isnt paused.

Here is the latest code:

Thanks in advance

I would recommend the following steps:

  1. Lose the async on line 21. You really don’t want it there.
  2. Lose the change to the TCP on line 21. It might not do any harm and you might actually need it, but let’s declutter a bit first.
  3. Lose the wait on line 25. It isn’t doing anything useful. It might be doing something harmful.
  4. If when you “test it” you go anywhere near the ‘Test’ button in the dashboard, don’t. You don’t want to run the piston manually, you want it to run automatically.

What exactly do you mean by “it doesn’t execute”? That it doesn’t do what you expect?

If you haven’t turned on the logs on the webCoRE dashboard, turn them on to full so you can see what actually happens. The logs should show the piston firing and running from the top whenever the contact sensor sends a contact event. Expect to be a bit surprised by what stays actually does if you don’t know how it works.

Thanks for tidying up the code. This has helped, I’ve managed to get the routine working to flash on a set of lights, and flash them when the door is open. This works consistently even without hitting the test button.

Ive then tried to add the sonos speaker action to line 21, but it doesn’t execute (or record that part in the logs).

I’ve added the log below (in chronological order):

14/01/2021, 18:42:05 +31ms
+1ms ╔Received event [My home].time = 1610649726469 with a delay of -1438ms
+53ms ║RunTime Analysis CS > 17ms > PS > 5ms > PE > 31ms > CE
+56ms ║Runtime (38824 bytes) successfully initialized in 5ms (v0.3.110.20191009) (55ms)
+57ms ║╔Execution stage started
+62ms ║║Cancelling condition #5’s schedules…
+63ms ║║Condition #5 evaluated true (1ms)
+64ms ║║Cancelling condition #1’s schedules…
+65ms ║║Condition group #1 evaluated true (state changed) (4ms)
+67ms ║║Cancelling statement #7’s schedules…
+82ms ║║Executed physical command [Hue lightstrip plus 1].off() (4ms)
+88ms ║║Executed physical command [Hue lightstrip plus 1].on([delay: 1000]) (5ms)
+94ms ║║Executed physical command [Hue lightstrip plus 1].off([delay: 3000]) (5ms)
+135ms ║║Executed physical command [Hue lightstrip plus 1].on([delay: 4000]) (40ms)
+141ms ║║Executed physical command [Hue lightstrip plus 1].on([delay: 6099]) (5ms)
+142ms ║║Executed virtual command [Hue lightstrip plus 1].flash (69ms)
+143ms ║║Requesting a wake up for Thu, Jan 14 2021 @ 6:42:11 PM GMT (in 6.1s)
+147ms ║╚Execution stage complete. (91ms)
+149ms ║Setting up scheduled job for Thu, Jan 14 2021 @ 6:42:11 PM GMT (in 6.096s)
+155ms ╚Event processed successfully (154ms)

14/01/2021, 18:42:11 +40ms
+1ms ╔Received event [My home].time = 1610649731275 with a delay of -235ms
+55ms ║RunTime Analysis CS > 19ms > PS > 6ms > PE > 29ms > CE
+57ms ║Runtime (38818 bytes) successfully initialized in 6ms (v0.3.110.20191009) (55ms)
+58ms ║╔Execution stage started
+68ms ║║Cancelling statement #16’s schedules…
+80ms ║║Condition #10 evaluated false (5ms)
+81ms ║║Condition group #9 evaluated false (state did not change) (7ms)
+83ms ║╚Execution stage complete. (24ms)
+84ms ╚Event processed successfully (84ms)

  • I CLOSE THE CONTACT SENSOR *

14/01/2021, 18:42:26 +995ms
+1ms ╔Received event [Aeotec Open/Closed Sensor].contact = closed with a delay of 42ms
+45ms ║RunTime Analysis CS > 13ms > PS > 4ms > PE > 28ms > CE
+48ms ║Runtime (38833 bytes) successfully initialized in 4ms (v0.3.110.20191009) (45ms)
+49ms ║╔Execution stage started
+59ms ║║Comparison (enum) closed stays (string) open = false (1ms)
+61ms ║║Cancelling any timed trigger schedules for condition 5
+62ms ║║Cancelling statement #5’s schedules…
+63ms ║║Cancelling condition #5’s schedules…
+64ms ║║Condition #5 evaluated false (9ms)
+65ms ║║Cancelling condition #1’s schedules…
+66ms ║║Condition group #1 evaluated false (state changed) (11ms)
+71ms ║║Comparison (enum) closed changes_to (string) closed = true (0ms)
+73ms ║║Cancelling condition #10’s schedules…
+74ms ║║Condition #10 evaluated true (6ms)
+75ms ║║Cancelling condition #9’s schedules…
+76ms ║║Condition group #9 evaluated true (state changed) (8ms)
+78ms ║║Cancelling statement #15’s schedules…
+93ms ║║Executed physical command [Hue lightstrip plus 1].off() (4ms)
+101ms ║║Executed physical command [Hue lightstrip plus 1].on([delay: 1000]) (7ms)
+107ms ║║Executed physical command [Hue lightstrip plus 1].on([delay: 2099]) (5ms)
+108ms ║║Executed virtual command [Hue lightstrip plus 1].flash (24ms)
+109ms ║║Waiting for 2100ms
+2212ms ║╚Execution stage complete. (2164ms)
+2214ms ╚Event processed successfully (2214ms)

Thank you again for your assistance.

Post the updated Piston.

apologies i forgot to upload it in my last post, added now.