You have it backwards.
Rooms.members.forEach[room |
val target = TargetTemps.members.findFirst[r | r.name == room.name+"_Target"]
]
You have it backwards.
Rooms.members.forEach[room |
val target = TargetTemps.members.findFirst[r | r.name == room.name+"_Target"]
]
by the way, on the same note - is there a way to remove letters from the room.name?
like I have Kithchen_Temp and Kitchen_TargetTemp, so I would need to remove from Temp and add TargetTemp. otherwise, I guess I just need to create items with plain room names?
Of course, you can split things apart and recombine them all you want. See https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
However, you will have to weight the pretty significant increase in code complexity for, IMHO, dubious benefit. Given that the names of Items are something that only you see in the code, I would recommend sticking with a naming scheme that makes your code simpler rather than making the names more aesthetically pleasing to the reader.
In the first post, the first DSL example have a small error. The trigger line is before the ‘when’ and ‘then’…
I believe it should be:
rule "A Door's State Changed"
when
Member of gDoors changed
then
if(previousState == NULL) return;
postUpdate(triggeringItem.name+"_LastUpdate", now.toString)
end
Lights in my home automation setup may be controlled multiple ways: by a physical switch hardwired to the light, by a button on a UI screen, or by a rule in response to some other events. To keep it simple, I combine the design patterns for Proxy Items, for Groups and for Associated Items. I define rules for the desired behavior at the level of a group, and then assign the lights to that group.
With this setup, the proxy item will always correctly reflect the status of the light, independent of what caused that status (command from a rule, gesture on a physical control, gesture on a UI element).
A more detailed description can be found here.
The import for oH4 Rules DSL is different
import org.openhab.core.model.script.ScriptServiceUtil
Actually that’s what it should be for anything v3.0+. This is an old post. I’ll correct it.
The first line says Edit: Updates for OH 4
But I’ve long since dropped Rules DSL, so stuff gets missed during updates.
In OH 5 I intend to remove Rules DSL for all my Design Pattern posts entirely.