I would like to create a rule that sends an email alert if the humidity has been higher than x for more than 12 hours. We manage a number of HA systems and are hoping to move our platform over to OpenHAB but I need for people to be able to create rules like this without writing code and I’m hoping the new rule engine will provide this opportunity.
OK, so I wanted to start without the timer just to keep it simple and I did create a rule in the GUI that sends an email when the temp (using that as a proxy for RH right now) gets below a set level. The problem is that the trigger is when the sensor changes state so I get the alert every time the sensor updates instead of just once when the temp crosses the threshold. This is what it looks like:
When = an item state is updated (the temp sensor)
Then = execute a given script (the email script)
But only if = Outdoor Temp is less than x
So I tried something that was actually simpler and I hoped would work but it’s not triggering:
When = an item was changed from state > 39 to < 40
Unfortunately not. You’ll need to write some code to achieve this.
You can’t use greater than/equals in the trigger. You have to put those in a condition (i.e. “But only if…”). So you would trigger when the Item changes and then you can test in the condition whether the current state is over 40 and previous state is under 39. But that is going to require a Script Condition (i.e. some code).
Blockly doesn’t yet support Timers. Hopefully soon but not yet. You can’t call Actions from Blockly either (so no sendMail).
In general this is easily doable with a minimal amount of actual code, but it’s going to require some code.
Java is not JavaScript. They are two completely different languages. Don’t get confused and head down the wrong path. But it gets more complicated because All of the stuff you use to interact with openHAB from Rules is written in Java.
I don’t know what you mean by a cache but there are essentially dozens of examples here and there showing how to do various things in JavaScript rules.
Ah, thanks for clarifying. Yeah I just meant I should be able to find examples of things like a timer without having to actually try and reinvent the wheel.