Any way to setup two cron (schedules) that call the same handler?

Here's what I'm trying to do, I have a schedule() that runs at 8AM MON-FRI but at 10AM on SAT-SUN. My goal was to call schedule() twice with the different cron expression but call the same handler. I can't do that because the second call overwrites the first. Can I do this without creating unique handlers?

create dummy methods that call your real method..not much duplication

How I have gotten around this issue in NOAA was to have a unique second sub that I can call which then would reference my original.

Example:

Def routine1() { all the magic happens here }

Def routine2() { routine1() }

Runin(5, routine1)
Runin(240, routine2)

That's pretty much what I thought I was going to have to do but figured I'd ask if anyone had anything smarter. It's a little worse than I explained because I have 1 per day so I just have a lot of these dummy methods so figured I'd ask :slight_smile: Thanks guys!

1 Like

With runIn commands there is an option you can specify "overwrite: false" so you can call the same handler multiple times without overwriting the previous call.

The smartthings documentation (I sometimes reference this as its more complete) indicates that this is also available with the schedule command by passing it in the data but I have never tested it.

Might be something to look into.

I’ll give it a shot. The HE documentation does not list that.

Ya. I know I've used it with the runIn for a specific thing I was working on. But never with schedule so that's why I'm not sure if it will work with schedule. But the ST documentation mentions it working with schedule so who knows. Good luck.

Careful how you implement this. It can give you undesired results with infinite looping.

yup, if it really is variable, end up needing to do a runIn, and can just schedule a watchdog in case runIn misses, reboot, etc...

Not sure I follow. How is this likely to lead to problems? I just have something that runs at a different time on different days of the week so I'm putting that in the cron expression