Hello,
I’ve been using openhab as a simple UI for my smart house without automations.
Now i want to integrate the heating control into openhab using the rules/scripts.
I created a rule to control the contacts of the zone valve and the gas heater.
Is there a way to pass the items to the rule as arguments? I need this rule multiple times for each room, and it would be much easier.
Here’s my rule code:
configuration: {}
triggers:
- id: "2"
configuration:
itemName: HvacLiving_LivingTemperature
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/vnd.openhab.dsl.rule
script: >
val temperature = HvacLiving_LivingTemperature.state as Number
val hvacMode = HvacLiving_LivingHVACmode.state.toString
val setpointComfort = HvacLiving_LivingComfortTemperature.state as
Number
val setpointStandby = HvacLiving_LivingStandbyTemperature.state as
Number
val heatingValve = KNX_Device_heating_valve_living
val heatingContact = KNX_Device_cv_heat
val hysteresis = 0.3
// logInfo("TemperatureScript", "Current temperature is: " +
temperature.toString())
if (hvacMode == "COMFORT") {
if (temperature < setpointComfort){
heatingValve.sendCommand(ON)
heatingContact.sendCommand(ON)
logInfo("HVACModeScript", "Temperature is below the comfort level. Heating valve turned ON.")
}
else if (temperature > (setpointComfort + hysteresis)) {
heatingValve.sendCommand(OFF)
heatingContact.sendCommand(OFF)
logInfo("HVACModeScript", "Temperature is above the comfort range. Heating valve turned OFF.")
}
}
else if (hvacMode == "STANDBY") {
if (temperature < setpointStandby){
heatingValve.sendCommand(ON)
heatingContact.sendCommand(ON)
logInfo("HVACModeScript", "Temperature is below the comfort level. Heating valve turned ON.")
}
else if (temperature > (setpointStandby + hysteresis)) {
heatingValve.sendCommand(OFF)
heatingContact.sendCommand(OFF)
logInfo("HVACModeScript", "Temperature is above the comfort range. Heating valve turned OFF.")
}
}
else {}
type: script.ScriptAction