Comments (7)
Thank for for submitting this feature request, but the core helper libraries are only a temporary crutch until the rule engine has been further built out with features. It would be possible to implement something like this in Jython, but by implementing it in the rule engine, it could be used in rules built through the UI rule editor and any scripting language. There have been discussions about implementing Actions or Profiles as a replacement for the Expire binding functionality in OH 3.0.
That said, Area Triggers and Actions implements similar functionality by just adding some Item metadata.
from openhab-helper-libraries.
@boc-tothefuture what is the use case for this scenario?
from openhab-helper-libraries.
@mjcumming -
In this particular case I want to send a notification if any of my ESPHome devices go offline for more than 30 minutes. I have done this in the past with virtual items w/ the expire binding and creating and maintaining my own timers. However, I wanted an easier solution with little to no boilerplate.
from openhab-helper-libraries.
I use some ESP12Es and check that they are still online with the network binding. Here is the metadata I use to get a notification when either are offline for more than an hour...
set_metadata("Status_Network_ESP12E_01", "area_triggers_and_actions", {
"actions": {"notification_action": {"OFF": {"delay": 3600, "types": {"audio": True, "mobile": True}, "Priority": 0, "recurring": True}}}}, overwrite=True)
set_metadata("Status_Network_ESP12E_02", "area_triggers_and_actions", {
"actions": {"notification_action": {"OFF": {"delay": 3600, "types": {"audio": True, "mobile": True}, "Priority": 0, "recurring": True}}}}, overwrite=True)
from openhab-helper-libraries.
#233 provides a library that does all the Timer management book keeping for you. With one function call (check()
) you can create a new timer or reschedule it if it already exits. You pass it up to two functions, one that optionally gets called if the Timer already existed when check was called and the other that gets called when the Timer expires.
So for the simple case where you want a Timer to check when foo is ON for five minutes
from core.rules import rule
from core.triggers import when
from community.timer_mgr import TimerMgr # probably should go in personal.timer_mgr until/if it gets merged
timers = TimerMgr()
def on_too_long(itemName):
# what you do when the timer expires
@rule("timers for being on too long")
@when("Item foo changed to ON")
def changed_on(event):
timers.check(event.itemName, 300000, lambda: on_too_long(event.itemName))
With the above code, if no Timer exists when check is called with the name event.itemName, one is created. If check is called before the timer triggers it gets cancelled. If check isn't called before the five minutes is up on_too_long gets called.
The library also has the option to reschedule the timer instead of cancelling it and you can pass an optional function to it to that gets called when check is called and the Timer already exists, useful for sending alerts that an Item is flapping for example.
from openhab-helper-libraries.
@rkoshak -
This does not cancel the timer if the item get changed to "OFF", Correct? That logic would still need to be implemented (potentially in the on_too_long method).
from openhab-helper-libraries.
This issue is resolved and the requested feature will not be implemented. If you wish to discuss alternatives, please do so in the forum.
from openhab-helper-libraries.
Related Issues (20)
- Remove "Member of" and "System started" triggers
- core.metadata get_metadata duplicate lines of code HOT 2
- Add a module for storing data to persistent storage
- event.ItemState returning incorrect state for Rollershutter HOT 1
- [Area Triggers and Actions] Make "99/100" state override configurable HOT 2
- [Area Triggers and Actions] Refactor light_action HOT 2
- [Area Triggers and Actions] light_action throws exceptions HOT 2
- [Area Triggers and Actions] Configurable brightness method for light_action HOT 1
- Return missing in utils.js Line 206 HOT 1
- timer_example.py link in documentation is a 404. HOT 1
- [utils] kw function is broken
- The WeatherStationUploader community script is obsolete and should be removed HOT 2
- _DirectoryEventTriggerHandlerFactory doesn't work HOT 3
- Javascript doesn't works with current OH 3.0 daily build
- openhab-helper-libraries/Getting Started/Installation suggestions HOT 2
- [actions] LogAction was renamed to Log in OH 3.0
- joda.time is no longer part of the OpenHab 3 Core HOT 2
- Openhab 3 . Channel Trigger WHEN error / MQTT action HOT 5
- WHEN Trigger for Things HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openhab-helper-libraries.