KNX - Calculation of Setpoint Shift for heating

Hi all,
I would like to share my option to calculate the shift of the setpoint for heating actuator. (German: Sollwertverschiebung)
I had set the default setpoints for all rooms to 21°C and wanted to do the individual adjustment only via openhab.

I have installed a MDT Heating Actuator AKH and I’m using following communication objects for exchange with openhab:
Setpoint Comfort (German: Sollwert Komfort) - Preconfigured temperature in the ETS
Setpoint Shift (German: Sollwertverschiebung)
optional: Setpoint Actual (German: Aktueller Sollwert)
optional: Status Valve (German: Status Stellwert)

Thing definition:

Thing device HeatingActuator_F1 "Heating Actuator 1st Floor" [
    ] {
        Type number            : Channel_A_StatusValve        "Channel A - Status Valve"                    [ ga=" 5.001:<7/2/61" ]
        Type number            : Channel_A_SetpointComfort        "Channel A - Setpoint Comfort"                    [ ga=" 9.001:<7/1/61" ]
        Type number            : Channel_A_SetpointActual        "Channel A - Setpoint Actual"                    [ ga=" 9.001:<7/1/62" ]
        Type number-control    : Channel_A_SetpointShift   "Channel A - Setpoint Shift"               [ ga=" 9.002:7/1/63" ]
      }     

Item definition

// HEATING
Group                 F1_Office_Heating                    "Heating"                 <heating>     (F1_Office)                                               ["RadiatorControl"]
Number                F1_Office_Heating_SetpointActual     "Setpoint Actual"                       (F1_Office_Heating)                                                                      {channel="knx:device:bridge:HeatingActuator_F1:Channel_A_SetpointActual"}
Number                F1_Office_Heating_SetpointShift      "Setpoint shift"                        (F1_Office_Heating)                                                                      {channel="knx:device:bridge:HeatingActuator_F1:Channel_A_SetpointShift"}
Number                F1_Office_Heating_SetpointComfort    "Setpoint Comfort"                      (F1_Office_Heating)                                                                      {channel="knx:device:bridge:HeatingActuator_F1:Channel_A_SetpointComfort"}
Number                F1_Office_Heating_StatusValve        "Status Valve [%d %%]"    <pressure>    (Groups_Heating_Valve_F1, F1_Office_Heating)              ["Status", "Property"]         {channel="knx:device:bridge:HeatingActuator_F1:Channel_A_StatusValve", unit="%"}
Number:Temperature    F1_Office_Heating_SetpointRequest    "Heating Setpoint"        <heating>     (Groups_Heating_SetpointRequest_F1, F1_Office_Heating)    ["Setpoint", "Temperature"]    {listWidget="oh-stepper-item"[step=0.5,max=28,min=18], setpointComfortItem="F1_Office_Heating_SetpointComfort", setpointShiftItem="F1_Office_Heating_SetpointShift"}

JavaScript Rule:

rules.JSRule({
    id: "Heating_CalculateSetpointShift",
    name: "Heating - Calculation Setpoint Shift",
    description: "Rule calculates the Shift of a heating setpoint based on the user demand",
  triggers: [triggers.GroupStateChangeTrigger('Groups_Heating_SGroups_Heating_SetpointRequest_F1'),triggers.GroupStateChangeTrigger('Groups_Heating_SetpointRequest_F2')],
    execute: (event) => {
      let logger = log("Heating_CalculateSetpointShift");
      logger.debug("Heating - Request setpoint was adjusted: " + event.itemName);
      setpointRequestItem = items.getItem(event.itemName);
      setpointComfortValue = items.getItem(setpointRequestItem.getMetadata('setpointComfortItem').value).state;
      setpointShiftItem = items.getItem(setpointRequestItem.getMetadata('setpointShiftItem').value);
      setpointShiftValue = parseFloat(event.newState) - setpointComfortValue;
      setpointShiftItem.postUpdate(setpointShiftValue);
      logger.debug("Setpoint request is: " + parseFloat(event.newState));
      logger.debug("Sollwert comfort is: " + setpointKomfortValue);
      logger.debug("Setpoint shift is: " + setpointShiftValue);
    },
    tags: ["Heating", "JS"],
  }); 

Working fine for me.
Thank you for feedback

1 Like

This looks like a good candidate for a rule template. Then the user can configure the Items instead of needing to use your Item names or being forced to change them in the code. See How to write a rule template for details and if you choose to do so and run into problems ping me and I can help.