WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 339 forks source link

Countdown Timer Rules #1265

Open dholbert opened 6 years ago

dholbert commented 6 years ago

Here's a key use-case that I'd love for the gateway to support: Whenever device $X turns on, the gateway waits N minutes, and then turns off $X.

Concrete scenarios:

I can imagine this use case being supported via a specialized "Virtual Thing" (called "countdown timer", say) that automatically switches itself off after it's been on for N minutes. (The user could then configure rules in the IOT Gateway to make this virtual thing mirror/control the on/off state of a real device. Alternately: perhaps there could be a special "brick" in the Rules Editor, or perhaps some other method to address this use case. Not sure what's best, but I'm filing this issue to track this use-case, however it ends up being supported.

(Note: I initially brought this up in https://github.com/mozilla-iot/gateway/issues/515#issuecomment-370579504 but it was out of scope for that issue; hence, filing this one)

pchri commented 6 years ago

Take a look at some very early work in https://github.com/pchri/countdown-timer-adapter. It actually supports both your use cases.

dholbert commented 6 years ago

Thank you @pchri - that sounds perfect!

(I'm only familiar with adding new types of things via the iot gateway "Add-ons" UI, and the "Virtual Things" add-on in particular. Do you know if this will end up being discoverable in one or the other of those areas -- i.e. as its own add-on, or as part of the Virtual Things family of add-ons?)

pchri commented 6 years ago

@dholbert eventually it can be available in the gateway as a normal add-on, but it still needs some work before that. Or it could be added to Virtual Things. Or maybe someone can come up with a better solution.

Just wanted to let you know that I am working on it, because I see similar use cases as you do.

IGx89 commented 5 years ago

FYI, there's now a "TimerAdapter" in the adapter directory that can help address this deficiency as well: https://github.com/tim-hellhake/timer-adapter.

I've been trying to move over to WebThings Gateway from SmartThings and this is one of the main areas of functionality lacking for me. SmartThings can implement an occupancy sensor with a single rule (motion sensor triggers lights, with "Turn off after motion stops" checked and "After this number of minutes" populated) while WebThings needs three rules and a virtual timer PER sensor. Sooo ugly :(