I’d like to create a rule like
When
Item Item1 changed or Item Item2 changed
Then
sencommand (triggeredItem, 25)
End
Is that possible?
I’d like to create a rule like
When
Item Item1 changed or Item Item2 changed
Then
sencommand (triggeredItem, 25)
End
Is that possible?
It is possible with the JSR223 addon, but then you have to write your rules e.g. in Jython.
With the normal rule engine it is not possible. There have been various threads about it.
Sorry for not searching.
Thanks for the hint.
NOTE: as of the last time I checked (granted that was a couple of weeks ago) JSR233 was still only OH 1.x.
If you have persistence and your two Items are never going to trigger really close together (within the same half second for example) you can:
Thread::sleep(100) // give persistence a change to store the result
val triggeredItem = if(Item1.lastUpdate.isBefore(Item2.lastUpdate)) Item1 else Item2
Note: if you have more than two you can use a Group:
Thread::sleep(100) // give persistence a change to store the result
val triggeredItem = MyGroup.members.sortBy[lastUpdate].last
Also note I just typed in the above. My OH server is down for the moment and I’m in the process of rebuilding it, this time with Ansible scripts so next time I’ll at least have everything well documented.
Thanks for this input.
However @MikeH pointed me to a solution with pure OpenHAB rules (he removed his post )
Here is what I’m using in order the control the maxVolume of my Sonos Boxes (they could be set to 100% by a false touch and Sonos doesn’t have a feature to limit the volume).
val Number MaxVolume=25
rule “MaxVolumeChecker”
when
Item PlayKueche_Volume changed or
Item PlayGaestezimmer_Volume changed or
Item PlayWZ_L_Volume changed
then
gPlayer_Volume.allMembers.filter(s | s.state >= MaxVolume).forEach[ s |
sendCommand(s,MaxVolume)
]
end