[SOLVED] Help me understand: Controlling Setpoints on one device with another one by linking items to multiple channels

I would only link one item to one channel, each item representing what it’s linked to.

Group TemperatureControls

Number:Temperature Control_setpoint_temp (TemperatureControls) { channel="Channel_Link_ThingControl_setpoint_temp", autoupdate="false" }
Number:Temperature Valve1_setpoint_temp (TemperatureControls) { channel="Channel_Link_ThingValve1_setpoint_temp", autoupdate="false" }
Number:Temperature Valve2_setpoint_temp (TemperatureControls) { channel="Channel_Link_ThingValve2_setpoint_temp", autoupdate="false" }

File Based Rule in JRuby:

rule "Synchronize temperature controls" do
  changed TemperatureControls.members, for: 10.seconds
  run do |event|
    TemperatureControls.members.ensure.command event.state
  end
end

What that does:

  • When any member of the TemperatureControls group changed and stayed stable for at least 10 seconds:
  • propagate the new state to all members of the group whose state aren’t already the same (this is what ensure above does. It’s the same as sendCommandIfDifferent in jsscripting/jython). In this case because the item that triggered the event already had the same state, the command won’t be sent to it.

The for: 10.seconds gives you a free timer that does all the checks for you behind the scenes, so that if the state changes rapidly e.g. someone changing their mind within 10 seconds, the other items won’t get noisy commands that keep changing.

UI Based Rule in JRuby

You can implement something similar in a UI rule, by setting a group member trigger as usual, and write this in your rule body:

debounce_for 10.seconds do
  TemperatureControls.members.ensure.command event.state  
end

Again, with these few simple lines, you are getting for free, a lot of of features that you don’t have to code yourself. Traditionally you’d have to write a whole bunch of timer code and checks to achieve this but in jruby this is all part of the standard helper library.

Whilst the Semantic model can help with “finding” the other radiators, it doesn’t help you set up the trigger. For that, the plain “trigger on group member” approach is still the best way to do this.