Misbehaving piston?

I’m at a loss as to what’s happening here. No doubt a dumb mistake on my part, but this really has me mystified.

I have some outdoor holiday lights connected to smart plugs. I want them to go on at sunset (around 4:15pm this time of year, ugh) and off at sunset (7:45am, also ugh). BUT – the lights have their own internal timer that automatically shuts them off after 6 hours. BUT – “disconnecting” (or turning off) the power resets the timer. No problem, right? Every five hours, turn them off for a few seconds, then back on.

So here’s my piston and my event log from last night for one of the lights.

From the log we can see:

  • The lights were turned on at sunset – 4:17.
  • The piston fired at 9:17 (5 hours, right on time) but instead of sending an OFF command, pausing, and sending an ON command, we see that the light received two OFF commands.
  • At 10:17, I noticed the lights weren’t on, so I turned them on via the SmartThings app.
  • At 3:17, the piston should have fired . . . . but no commands were sent to the lights.
  • At 6:17, I noticed the lights weren’t on. Since no OFF command had been received, it must have been due to the lights’ 6-hour timer expiring. So again, I turned them on via SmartThings.
  • At sunrise (7:45), the piston fired and turned off the lights.

What the heck is going on here?

ETA: Just did the very same thing again tonight – two OFF commands. And BTW, the original wait was 5 seconds, which is what you see in the event log. I was originally thinking there might be a timing issue, so I increased the wait to 1 minute, which is what you see in the piston.

Here’s the trace log tonight from WebCORE:

Well, my first question is, why not simply remove the timer from the lights. Since you are controlling them yourself, you would do well, to just remove the timer from them so that you can control them yourself. So, I would not do this with the trigger you are using, I would do it with a variable. And I would also use the internal sunset and sunrise presets. So, my piston would look like this:

Define: next_cycle as date/time
cycle_done as boolean

Happens every day @ sunset:
Turn on Switches
Set variable cycle_done to false
set variable next_cycle to expression [ addMinutes ($now, 345) ]

Happens every day at variable next_cycle
with restriction cycle_done is false
Turn off switches
Wait 3 seconds
Turn on switches
set variable next_clycle to expression [ addMinutes($now, 345) ]

Happens every day at Sunrise
Turn off switches
Set variable cycle_done to true

But that’s just how I would do it.

I had a similar issue myself with a light display that has an in-built 6-hour timer that cannot be defeated. You have to power cycle the fixture to get it to come back on or wait for it’s timer to come back on after n-hours. I did the following. You can probably use something similar for your situation. Note, I had to do it this way because ST does not always update the status of a device promptly. The way I coded this works without fail. Below the piston image I have posted the thread this came from for context.

I’m dashing out so can’t read the webCoRE log and probably wouldn’t understand it anyway, but quickly …

The triggers for the piston are when either of the lights has been on for five hours. So after five hours the piston will run once for Switch 34 having been on for five hours, and once for Switch 35 having been on for five hours. So that why you have two off events.

Later edit: Though looking at the webCoRE log, if that IS what is happening it isn’t obvious so maybe I am talking rot. I do see two triggers though.

I think the lack of on events is because of the setting of the ‘Task Cancellation Policy’ which I believe defaults to cancelling the wait if the conditions that triggered it have changed. As the lights have been switched off they have no longer been on five hours so the task gets cancelled.

Later edit having examined the log: Was the timing different for the webCoRE log? Were you hovering waiting to switch the lights on manually an hour earlier on this occasion? Only I don’t see webCoRE turning the lights on, only responding to them being having turned on.

[Probable drivel about the ‘missing’ piston execution deleted]

Later edit: I can’t get my head around the lack of anything happening at 3:17am. Is there any webCoRE logging for 2:17am–ish or 3:17am-ish?

Thanks. As with @Nezmo’s case, there is no way to disable the time.

Thanks. I also looked at the thread you linked to because the discussion helped shed some light on the “why” as well as the “how”.

@Nezmo, FYI, this seems to work. Thanks again.

Good deal. There’s definitely more than one way to skin a cat with webCoRE.