Howto combine 3 rules into one

Hi,

I’m working on my habpanel widget for controlling the heating (Opentherm binding) together with some rules.
Status:

  • Binding works
  • Items are working with binding
  • Can update the setpoint temperature
  • Rules work

Here’s the widget (it’s under development, so it does not look ok yet…):
image

the left temperature is the room temperature
the icons in the middle will change color depeding on the state (e.g. burner active will result in a colored flame)
The right-side temperature is the setpoint value temperature from the thermostat.
But, the setpoint can be set with 3 options:

  1. Physically on the thermostat
  2. By setting the room_setpoint_Override (temporary new temperature until the thermostat has a fixed temp set by timer)
  3. By settting the constant_override. This temperature will remain and is what I use in my heating rules

And there is always a delay in setting the temperature through option 2 and 3 (because of how OTGW works)
And I want the setpoint to change when I use the arrow up or arrow down. Therefore I needed a “helper” Number for the display in habpanel.

The displayed temperature on the rightside of the widget in habpanel code is (with the arrows for control):

Habpanel:

<div class="otgw-item-e">
  	<img ng-src="{{ServerPath}}/static/icons/temp-up.png" height="20px" width="20px" ng-click="sendCmd('otgw_RoomSetpointOverride', +itemValue('otgw_habPanel_Temp').split(' ')[0]+0.2)"/>
  </div>
  <div class="otgw-item-f">
          {{'%.1f'| sprintf: itemValue('otgw_habPanel_Temp').split(' ')[0]}}&nbsp;°C
  </div>
  <div class="otgw-item-g">
  	<img ng-src="{{ServerPath}}/static/icons/temp-down.png" height="20px" width="20px" ng-click="sendCmd('otgw_RoomSetpointOverride',+itemValue('otgw_habPanel_Temp').split(' ')[0]-0.2)"/>
  </div>

The items:

Number:Temperature otgw_RoomTemp "Current room temperature: [%.1f %unit%]"  (OTGW_ITEMS)    {channel="openthermgateway:otgw:OTGW:roomtemp" }
Number:Temperature otgw_RoomSetpoint "Room setpoint: [%.1f %unit%]" (OTGW_ITEMS)    {channel="openthermgateway:otgw:OTGW:roomsetpoint"}
Number:Temperature otgw_RoomSetpointOverride "Room setpoint override: [%.1f]" (OTGW_ITEMS) {channel="openthermgateway:otgw:OTGW:temperaturetemporary"}
Number:Temperature otgw_RoomConstOverride "Room contstant override: [%.1f]" (OTGW_ITEMS)   {channel="openthermgateway:otgw:OTGW:temperatureconstant"}
Number:Temperature otgw_ControlSetpoint  "Control setpoint: [%.1f %unit%]" (OTGW_ITEMS)       {channel="openthermgateway:otgw:OTGW:controlsetpoint"}
Number:Temperature otgw_DomesticHotWaterTemp "Domestic Hot Water temp: [%.1f %unit%]" (OTGW_ITEMS)  {channel="openthermgateway:otgw:OTGW:dhwtemp"}
Number:Temperature otgw_DomesticHotWaterSetpoint "Domestic Hot Water setpoint: [%.1f %unit%]" (OTGW_ITEMS)    {channel="openthermgateway:otgw:OTGW:tdhwset"}  
Number:Temperature otgw_DomesticHotWaterSetpointOverride "Domestic Hot Water setpoint override: [%.1f %unit%]" (OTGW_ITEMS)    {channel="openthermgateway:otgw:OTGW:overridedhwsetpoint"}
Number:Temperature otgw_BoilerWaterTemp "Boiler Water temp: [%.1f %unit%]" (OTGW_ITEMS) {channel="openthermgateway:otgw:OTGW:flowtemp"}
Number:Temperature otgw_ReturnWaterTemp "Return Water temp: [%.1f %unit%]" (OTGW_ITEMS){channel="openthermgateway:otgw:OTGW:returntemp"}
Number:Temperature otgw_OutsideTemp "Outside temp: [%.1f %unit%]" (OTGW_ITEMS)     {channel="openthermgateway:otgw:OTGW:outsidetemp"} // NOT IN USE BY HOME SETUP
Number:Pressure otgw_CentHeatingPressure "Central Heating Pressure: [%.1f %unit%]" (OTGW_ITEMS) {channel="openthermgateway:otgw:OTGW:waterpressure"} // NOT IN USE BY HOME SETUP
Switch otgw_CentHeatingEnabled "Central Heating Enabled: " {channel="openthermgateway:otgw:OTGW:ch_enable"}
Switch otgw_CentHeatingActive  "Central Heating Active: " {channel="openthermgateway:otgw:OTGW:ch_mode"}
Switch otgw_DomesticHotWaterEnabled "Domestic Hot Water Enabled: " {channel="openthermgateway:otgw:OTGW:dhw_enable"}
Switch otgw_DomesticHotWaterActive "Domestic Hot Water Active: " {channel="openthermgateway:otgw:OTGW:dhw_mode"}
Switch otgw_BurnerActive "Burner Active: "   {channel="openthermgateway:otgw:OTGW:flame"}
Number otgw_RelativeModLevel "Relative Modulation level: "    {channel="openthermgateway:otgw:OTGW:modulevel"} // NOT IN USE BY HOME SETUP
Number otgw_RelativeModLevelMax "MAX Relative Modulation level: "{channel="openthermgateway:otgw:OTGW:maxrelmdulevel"} //NOT IN USE BY HOME SETUP
String otgw_SendCommand "Send OTGW_Command: " {channel="openthermgateway:otgw:OTGW:sendcommand"}

//Below are items for the heating AUTOMATION!

Number otgw_auto_target "Override for automation [%.1f]" (OTGW_AUTO_ITEMS) {channel="openthermgateway:otgw:OTGW:temperatureconstant"}
String otgw_Heating_Mode "Current heating mode [%s]" //String type for setting / reading the current "rule"
Number otgw_PresetTempNormal "Heating preset (Normal Mode) [%.1f]" //Temp for normal mode
Switch otgw_UpdateHeaters "Send Target Temperatures to Heaters"

//helper for setting room temperature by Habpanel
Number:Temperature otgw_habPanel_Temp "HabPanel temperature [%.1f]"

For showing the correct “setpoint” value in the widget, I have to consider:

  1. a change of setpoint by manual / physical change on the thermostat
  2. a change of setpoint initiated by room_setpoint_override on the widget
  3. a change of setpoint initiated by my heating rules

I now have 3 very small / simple rules for correcting the “otgw_habPanel_Temp” item
But I would like to consolidate it into 1 with OR statements in the “when” part of the rule.

The actual question
The question now is, how can I determine which of the 3 items triggered the rule, so I update the display value with the corret new value?

Here are the rules:

Rules:

rule "Correct Item otgw_habPanel_Temp (manual at thermostat)"
when 
    Item otgw_RoomSetpoint changed  
      
then 
    otgw_habPanel_Temp.postUpdate(otgw_RoomSetpoint.state as Number)
    logInfo("OTGW_Heating.rules", "Room Setpoint changed, otgw_habPanel_Temp: "+ otgw_habPanel_Temp.state as Number)
end

rule "Correct Item otgw_habPanel_temp with TT"
when 
    Item otgw_RoomSetpointOverride changed 
then 
    otgw_habPanel_Temp.postUpdate(otgw_RoomSetpointOverride.state as Number)
    logInfo("OTGW_Heating.rules", "Room Setpoint override(TT)changed, otgw_habPanel_Temp: "+ otgw_habPanel_Temp.state as Number)
end 

rule "Correct Item otgw_habPanel_temp with TC"
when 
    Item otgw_RoomConstOverride changed 
then 
    otgw_habPanel_Temp.postUpdate(otgw_RoomConstOverride.state as Number)
    logInfo("OTGW_Heating.rules", "Room Setpoint const override (TC) changed, otgw_habPanel_Temp: "+ otgw_habPanel_Temp.state as Number)
end 

What I would like…just to optimize is something like:

rule "Correct Item otgw_habPanel_Temp (manual at thermostat)"
when 
    Item otgw_RoomSetpoint changed or
    Item otgw_RoomSetpointOverride changed or
    Item otgw_RoomConstOverride changed
then
   otgw_habPanel_Temp.postUpdate(now I need to know which of the items triggered the rule)
end

thanks in advance!
/Jasper

when 
    Item otgw_RoomSetpoint changed or
    Item otgw_RoomSetpointOverride changed or
    Item otgw_RoomConstOverride changed
then
   otgw_habPanel_Temp.postUpdate(triggeringItem.state as Number)
end

See implicit variables in rules there:

That’s a bit embarrassing, while I’ve gone through the guide. I even thought of comparing previous and new state of the items to determine this…pfff
But thanks! I’ll change and check!