App: Switch Scheduler and More. (Schedule: Lights, Outlets, Switches, Relays, Sprinklers, Valves, and more..)

Just tried this and it looks good but doesn't do one thing that I was hoping it would... I'd like to add multiple lines for the SAME device (i.e. Multiple discrete time for ON and OFF for a device (including different times on particular days). My application isn't a sprinkler. Any way to do this?

Actually, after thinking about it... Although the way I described would be nice, it's pretty easy to just create another app definition for each required change.

So, for example, I could have
Monday on at 2:15pm for 1 hour as my day 1 schedule

Monday on at 9pm for 30 minutes for my night 1 schedule , etc ..

Even for the same device. Then if I name them with a suitable prefix they will all sort together as I want them.

After playing with it for a while, I find that I often get errors when setting the schedule... examples:
ava.lang.NullPointerException: Cannot invoke method length() on null object on line 536 (method updated)

java.lang.NumberFormatException: null on line 512 (method updated)

When this occurs (often) the schedule doesn't get set. It seems like maybe it has something to do with the 2x daily option? I'm not using that, but I've sometimes gotten it to work if I activate 2x, then de-activate it, then save settings. Unfortunately this seems hit-and-miss. Is there something I'm doing wrong?

Here's a sample setting:

I found an issue with the 2nd run time because there's some cases where it can try to schedule >24hr time. Uploaded the fix. Not sure if that fixes what you are seeing.

I will update and let you know. Until then, if it helps.. I found that I'd get the error if I set up a schedule (1x), but if I change to 2x, then back to 1x (even before refreshing or saving), then when I saved it was ok. Almost seems like an uninitialized variable with a null value...

Just found this and installed it to run my sprinklers, we shall see how it does tomorrow.

I wrote the Precipitation Monitor for NWS data back in 2022 with the intention of turning my dumb controller into a smart controller and now I'm finally getting around to it.

If the Precipitation Monitor detects more than X inches (user configurable) of rain the prior day it sets the sensor to the appropriate wet/dry value at a configurable time so this will work great with your app.

I'm hoping to cut our water bill significantly this year. Partly from the water sensor and partly because adjusting the times and durations on the actual physical controller was so painful that I rarely did it and probably over watered, especially in the spring and fall.

Looks excellent BTW. Thanks for taking the time to write this and share it.

@kampto Well the schedule all worked great but it ignored the "Pause if wet". We had 1.66 inches of rain in the last 24 hours so it's wet, wet, wet right now.

App reads the wet\dry sensor correctly but either ignores it or I'm misunderstanding the configuration process.


I will look into it. Thanks, for testing.

Update: Found the issue and ran a test to confirm.

Go to line #429 in Apps code and get rid of that "d", its a typo. should be "state.wetSensorValue". Go open app and hit update/store or done.

Also updated github.


This looks great, and cannot wait to try it.
Is it available on HPM yet?

This has been working very well for me but I recently created a new schedule for a sprinkler zone that gives me this error when it runs.

I added a couple of debug lines to see if I could figure out what was null:

def onTimeHandler(evt) { ("Event is: $evt") ("Event Device is: ${evt.device}") ("Event Device ID is: ${}")
    state.DeVices[].start = now()
    state.DeVices[].counts += 1  
    if (logEnableBool) { "${app.label} - ONtime HANDLER, Device ${evt.device}.....start= ${state.DeVices[].start}" }

For some reason there are two event and the event handler is called twice.

This is the line its complaining about.

state.DeVices[].start = now()

This is the state data and it does show the device listed with a value for start.

Any ideas?

There's a newer version 1.4.2 on github, not sure if it would solve this. Can you screen shot the app page so I know how you have it configured, then I can try to reproduce

1 Like

I tried the new version and no change. There is an issue with the subscriptions. The app is failing to unsubscribe removed devices.

I removed Zones 4,5 and 6 from this configuration.

But they are still subscribed to the handler.

Certainly explains why the handler was called twice and is getting a null, because it is not configured as a device within the setup.

Easy fix at the start of initialize()

//Remove all existing subscriptions.

Yeah, I didnt think about what would happen when removing anything from the table. Did you get that to work because dont think it will call unsubscribe() by simply removing a device.
I will think about this scenario.

I added it as the first line of your initialize() function. Works for me.

Hey @kampto been using this app for my watering needs, and it's working great. I am about to switch out my 4 watering valves with new ones will the issue that @garyjmilne mentioned come into play by removing the 4 old ones?

Yes, at the current moment if you remove a device from the existing app it will throw an error and wont be recoverable. To remove a device you need to create a new user app without that device and add the valves/switches you want. Then delete old previous install from apps page. I put a note on the main page about that on the latest github file.
The fix @garyjmilne mentioned did not work, deleting a device still caused issues. Its on my to do list to figure out how to allow removing a device without bricking the installed app instance.

1 Like

Ok, that's easy enough to do. Can I just remove the app entirely and start over with a new install, will that work as well?

Interesting, it worked for me. It deletes all subscriptions just prior to re-subscribing using your existing code.

Yeah, just click here on the apps page and remove. Then reinstall new user app. You can keep the apps code or get the latest on github.

1 Like

Interesting, it worked for me. It deletes all subscriptions just prior to re-subscribing using your existing code.

In my case the app errors out before I can hit done which would call the initialize function. So it never makes it to subscriptions. I need to look into it. But the app itself works fine.