Automatically Poll Virtual Devices

I wrote a virtual device for the garage door, with a door sensor and a zrf113 to control the door. I set up scenes based on the door sensor tripped events to change the status of the virtual device. It works great, but I’d like to add one more thing.
I’d like to regularly check the status of the door sensor and update the virtual garagedoor device - similar to device polling. It would be really nice to be able to just add the virtual device the polling queue and give it a function that runs every time vera tries to poll it.
Any thoughts on how to accomplish this?

Take a look at the timer call that’s in the Weather plugin. If your Device is already as a plugin, it’ll be easy enough to include the timer code from the Weather plugin inside your code to run “something” periodically.

Thanks Guessed - I was thinking about using call_timer, and I will probably end up doing that. The only concern I have about call_timer is it apprears that the function will then depend on itself completing - so if it fails to complete one time, it will never run again. I actually use call_timer in the garage door virtual device - to close the contacts, wait one second, then open them. I’ve also been using it to trip a virtual sensor at sunrise and sunset. I haven’t seen it fail yet, but the concept for the garage door is for an extra check to make sure the door really is closed, just in case a trip event doesn’t trigger the virtual dev. I’m probably just being paradnoid…

I haven’t seen it fail yet. If you want to be really paranoid, run 2 call_timers. One that runs every 60 seconds and does the checks, plus whatever else is done during this checking phase.

The second runs every 30 minutes and only checks that the other one is running - restarting everything if it detects failure. This one needs to have a very small amount of code running in it so it doesn’t fail.

It’s probably overkill though.

I’m assuming you’re concerned about your code inside the Call_timer failing/hanging, and not Call_timer itself being buggy or whatever. :wink:

I concur, the way guessed suggested is reliable enough.
I use it in my Etherrain plugin to monitor its state - never had a problem

Guess, i’m more concerned about the code failing or catching it in a weird scenario where i might be trying to close the garage door through vera at the same time that my girlfriend is at the house opening the door with the opener. I just found a simple fix for this - set a call timer to verify the door is closed 20 seconds after closing it through vera… duh…
Now I just have to make it notify me if it doesn’t close. I’m assuming I can do this in lua…