[OBSOLETE] "Pollster" - A SmartThings Polling Daemon

Like the new code…

With the Switch on off feature does activating the switch turn off your code and when the switch goes off your pollster will run again?

From the “Scheduling Limitations, Best Practices, and Things Good to Know” section of Scheduling page in the SmartThings documentation:

Do not use runIn to set up a recurring schedule of less than sixty seconds

You may have noticed that none of the schedule APIs allow you to schedule jobs for less than sixty second intervals. You may be tempted to work around this limitation by using runIn to create such a schedule (i.e., a handler method that reschedules itself). This is discouraged, and at some point may be prevented by the SmartThings framework.

The primary reason for discouraging jobs that run more often than every sixty seconds is overall system resource utilization. Using runIn to circumvent this is problematic because any failure to execute, even once, will cause the scheduled event to stop triggering.

Not possible. Please read the docs.

I started running version 1.4.1. It got about four iterations before it ran into a problem. Now it is waiting for one of the events to restart it again.

I also redid my changes to attach it to a temp sensor’s temperature change event. That one ran about 3 times before running into a problem but essentially restarted about 13 minutes later - 3 minute interval and a 10 minute safety addition. The new code is a lot easier to hook an event into.

All I did:

  1. In the preferences section, add a new prompt for a temp sensor.

    section(“Choose temperature sensor to monitor for changes to trigger a check as a backup”) {
    input “sensor”, “capability.temperatureMeasurement”, title: “Temp Sensors”, required: false
    }

  2. Add an event handler procedure.

def temperatureHandler(event) {
log.debug “My Pollster - in Temp Change Event Subscription Handler”

watchdog()

}

I put it after the updated() procedure.

  1. Add in the optional subscription to the temperature event in the initialize() procedure.

    if (numTasks) {
    subscribe(app, onAppTouch)
    subscribe(location, onLocation)
    subscribe(location, “position”, onLocation)
    subscribe(location, “sunrise”, onLocation)
    subscribe(location, “sunset”, onLocation)
    if (sensor) {
    subscribe(sensor, “temperature”, temperatureHandler)
    }
    }
    NOTE: only the “if (sensor)… }” is what I added the rest is to show where.

Since I am using pollster to get new thermostat and weather information it makes sense to attach it to a change in a regular temp sensor - at least for me, anyway.

Forgot to say - thanks for the update!

Thanks all that are working this code. Now if I could just get ST stable

They are currently actively playing with the scheduled tasks to try and get things under control - see This announcement. I don’t expect things to quiet down for another couple of days with regards to scheduling - the last few days have been extremely bad…

1 Like

Yeah, the platform has really gone to crappers. My instance kicked the bucket at 1:30 PM, in less than one hour!

The good news is that now you don’t even need to open Pollster to restart it. Just hit the “Play” button on the SmartApps page :wink:

1 Like

Actually, that wasn’t working most of the day either. I had to delete the instance and recreate it to get one going. This was with the 1.3.1 version. I just checked the 1.4.1 version and it did seem to restart after being down for an hour and a half. I expect it would have resumed at sunrise automatically.

The watchdog is definitely triggering. Here’s the log (in reverse order):

5:06:19 PM PST: info Pollster. Version Version 1.4.1. Copyright © 2014 Statusbits.com
5:06:18 PM PST: warn Polling task #1 stalled. Restarting…
5:06:18 PM PST: trace watchdog()
5:06:18 PM PST: trace onAppTouch(touch)

I don’t think the polling resuming after restart though. Anyway, the platform is almost unusable right now. It takes 30 seconds just to pull recent device activity. Will wait for big and shiny firmware update this Thursday and if the hub does not blow up we’ll see then. :slight_smile:

So does anyone know what blew up and why?

1 Like

Well, 1.3.1 was what I was referring to where the play didn’t work. With 1.4.1, it does. However, with the stock app if it doesn’t hit an event (sunrise, set, and location (is this presence?) change then it hangs:

interval_4:5]
063e5eef-8798-40de-87cb-7963655008e6 6:48:17 PM: info Pollster. Version Version 1.4.1. Copyright © 2014 Statusbits.com
063e5eef-8798-40de-87cb-7963655008e6 6:48:17 PM: warn Polling task #1 stalled. Restarting…
063e5eef-8798-40de-87cb-7963655008e6 6:48:17 PM: trace watchdog()
063e5eef-8798-40de-87cb-7963655008e6 6:48:17 PM: trace onAppTouch(touch)
063e5eef-8798-40de-87cb-7963655008e6 5:16:50 PM: trace pollingTask1()
063e5eef-8798-40de-87cb-7963655008e6 5:12:51 PM: trace pollingTask1()
063e5eef-8798-40de-87cb-7963655008e6 5:08:51 PM: trace pollingTask1()
063e5eef-8798-40de-87cb-7963655008e6 5:04:56 PM: trace pollingTask1()

Note the gap between 5:16:50 until 6:48:17 when I hit the play button to manually start it up again.

This is the log when subscribing to an event that happens more often:
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:33:06 PM: trace initialize() with settings: [group_1:[Lower Level Nest, Main Level Nest, Upstairs Nest, Weather Woodbury], interval_1:3, interval_2:5, interval_3:5, interval_4:5, sensor:Great Room Temp/Humidity]
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:33:06 PM: info Pollster. Version Version 1.4.1. Copyright © 2014 Statusbits.com
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:33:06 PM: warn Polling task #1 stalled. Restarting…
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:33:06 PM: trace watchdog()
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:33:06 PM: debug My Pollster - in Temp Change Event Subscription Handler
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:23:35 PM: trace watchdog()
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:23:35 PM: debug My Pollster - in Temp Change Event Subscription Handler
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:18:49 PM: trace watchdog()
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:18:49 PM: debug My Pollster - in Temp Change Event Subscription Handler
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:18:26 PM: trace pollingTask1()
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:15:35 PM: trace pollingTask1()
9bc2caf1-5985-4102-9190-c24a0cbf53b5 6:12:34 PM: trace pollingTask1()

This one was down for 16 minutes - thirteen from the app and it looks like a few minutes for the timing to work out with the temp reporting.

When I implemented watchdog in version 1.3 the stalling occurred very infrequently. I had Pollster running for several month without an issue and the scheduled watchdog task was sufficient to restart it when the failure occurred.

Then around September - October last year the failure rate increased to several times a month or even several times a week. I’ve noticed that the watchdog task itself started to fail which defeated the purpose of having the watchdog.

In 1.4, I use location events (sunrise/sunset, geofence and mode changes) to kick the watchdog. This ensures that it will run at least twice a day. However, with the scheduler failure rate every few hours, there’s not much you can do. You can tie the watchdog to every switch and motion sensor in your home, but who’s gonna trigger them when you’re not home? :smile:

1 Like

Well, I’d almost think they’ve turned off the runin functionality all together. The watchdog runs but nothing happens. The play makes it run once and then nothing. The events still fire…

Well, in MN in the winter the temp is always changing inside, even if nobody is home… :smile: I don’t recall seeing it go longer than 25 minutes or so all day.

Get a cat or a dog. Get two or more animals from a shelter. Tie Pollster to motions and then go freakin’ nuts with reliability. Wouldn’t this look good in some blog somewhere?

1 Like

True, the temperature will change without human intervention. Unfortunately, the only temperature sensor in my home is one in the 3M-50 WiFi thermostat, which requires polling to work. Actually, it’s the reason I wrote Pollster in the first place. :smile:

is there a way to make a virtual switch trigger the poll job? use Rule to make a function that turns off the switch and have a second function that turns on the switch after a delay?

Wow, I think that most, if not all, of my motion sensors have it. The SmartMoisture sensors do, too. The reason that I’m using pollster is because I have nest thermostats and need to get them updated so that I can use Keep it Cozy II to keep a couple of areas warm. The temp I’m checking the event on is one of those sensors - essentially when it changes temp I want to make sure that the nest is update to date… Complete opposite.

I guess I’m really wondering how did you manage to avoid them? I was thinking it was built into the radio chips, or something,strong text because it seems they are always in things you wouldn’t expect.

I have a bunch of Ecolink motion sensors that don’t have a temperature sensor built-in. I purchased one Monoprice recently, but I’m not adding any new devices until I decide whether to keep messing with ST or put it out of its misery. :smile: