Hi there, dear OH-enthusiasts,
I use the following rule to configure my appartment’s heating for the night. The first argument to sendCommandOnChange is an item, the second a desired temperature stored in an item.
rule "night"
when
Time cron "00 45 21 * * ?"
then
logInfo("heatingAutomation", "night")
sendCommandOnChange(HeizungSchlafenSoll, (HeizungSchlafenVollTemp.state as DecimalType).intValue)
sendCommandOnChange(HeizungWohnzimmerSoll, (HeizungWohnzimmerLeerTemp.state as DecimalType).intValue)
sendCommandOnChange(HeizungKuecheSoll, (HeizungKuecheLeerTemp.state as DecimalType).intValue)
sendCommandOnChange(HeizungBadSoll, (HeizungBadLeerTemp.state as DecimalType).intValue)
end
In order to save precious resources, my goal is to actually send temperature change commands only if there is a change from the current desired temperature (heaters are controlled by some quite sluggish radio controlled proprietary hardware). I’d like to accomplish this using the following lambda (which comes before the actual rule in the heatingAutomation.rules-file).
val sendCommandOnChange = [ GenericItem itm, Integer intVal |
if (intVal != (itm.state as DecimalType).intValue) {
itm.sendCommand(intVal)
}
]
However, I get the following error in the logs: Validation issues found in configuration model ‘heatingAutomation.rules’, using it anyway: This expression is not allowed in this context, since it doesn’t cause any side effects. From what I understood this can be fixed by returning some arbitrary value from the lambda (put e.g. true in it’s last line) and assigning the return value (to some dummy variable).
However, even then the lambda does not seem to be called, i.e. additional logInfo(…) commands in the lambda do not occur in the log. What am I doing wrong?!
Thanks a bunch for your kind help, guys!
ugh_bough
- Platform information:
- Hardware: RaspberryPi
- OS: Openhabian
- openHAB version: 2.3.0