rlkoshak
(Rich Koshak)
November 1, 2016, 9:18pm
5
You could create a lambda (i.e. function) but if all you are doing is dividing by 10 it will probably be less work and less lines of code to just do it inline in the rule.
Major Edit: Rewrote with the cleaner OH 2.3 syntax.
The example lambda on the OH 1 wiki is overly complex and as written will not work in OH 2. This quick example will show a super simple lambda example with copious notes.
Here is the code without comments. It takes in an Item, logs it’s state and returns a slightly modified version of the String logged.
val log= [ GenericItem s |
logInfo("lambda", s.state.toString)
s.state.toString + " logged"
]
rule "Call Lambda"
when
// some t…