Hi all,
I hope you can help!
Basics out of the way first - currently running OH 2.2 Snapshot 1112 on Ubuntu 17.10 (if you need any more info, just ask!)
I am using the wonderful Heating Boilerplate as a template home heating.
I have the basics set up, but in the guide above, it is assuming that each of the Target Temperature channels will do something - however I am going to be using some Sonoff devices with Thermal Actuators, switching them on/off as necessary to regulate the temperature.
I have decided to give this a try by setting up a Cronād rule, to run every X minutes (for initial testing every 5 minutes) to check temperatures, and turn on/off the Sonoff.
I will be having multiple heating zones, each with their own temperature schedules, and there may be one or more temperature sensors in each zone, and one or more radiators to control.
I have added all of the target temperature items into a group, so that in addition to the cron, it will be fired if any of these items are updated (so you donāt have to wait up to 5 minutes for a change to occur! That would have very poor WAF!).
As a starter for 10, I have the basic code below - when the rule fires, it will check a temperature sensor, compare it against the target, and if it falls within a range, set the actuator on or off.
rule "Check heating actuators every 5 minutes"
when
Time cron "0 0/5 * * * ?" or
Item gHeatingTargetTemp received update
then
var Number hylow = 0
var Number hyhigh = 0
hylow = (OF_Heating_TargetTemp.state as Number) - hysteresis
hyhigh = (OF_Heating_TargetTemp.state as Number) + hysteresis
if ((OF_Temp1.state as Number) < hylow) {
OF_Heating_Actuator.sendCommand(ON)
} else if (((OF_Temp1.state as Number) > hylow) && ((OF_Temp1.state as Number) < hyhigh)) {
OF_Heating_Actuator.sendCommand(ON)
} else if ((OF_Temp1.state as Number) > hyhigh) {
OF_Heating_Actuator.sendCommand(OFF)
}
hylow = (ME_Heating_TargetTemp.state as Number) - hysteresis
hyhigh = (ME_Heating_TargetTemp.state as Number) + hysteresis
if ((ME_Temp1.state as Number) < hylow) {
ME_Heating_Actuator.sendCommand(ON)
} else if (((ME_Temp1.state as Number) > hylow) && ((ME_Temp1.state as Number) < hyhigh)) {
ME_Heating_Actuator.sendCommand(ON)
} else if ((ME_Temp1.state as Number) > hyhigh) {
ME_Heating_Actuator.sendCommand(OFF)
}
end
I could then copy/paste and repeat for each sensor/actuator pairings.
This doesnāt yet also deal with the situation where I have multiple sensors for one zone (where I would want to average the value) - multiple actuators is again a simple case of copy/paste.
However - this is of course wasted code, and it means if I want to add devices, I will need to copy/paste, and thatās another thing Iāve got to remember to do.
All the Actuators are then part of another Switch group, and if any of them are ON, it should then switch the boiler/pump on to actually generate some heat.
What I think would be the best method, would be to be able to add all temperature sensors and actuators to a group - and have all members of this group iterated through, all temperatures averaged out, and all actuators turned on/off.
This is where Iām struggling to get my head around how Iād start to do thisā¦
I have had a look at the Using Groups In Rules Design Pattern thread, and canāt get my head around it yet - that example appears to be using a single rule to act upon the item that triggered it - I am looking to act upon all items within groups, and use one type of item from one group (temperature sensors) to act upon another type of item in the group (switches), when an item in a group changes (target temps) or on a timerā¦
I hope that makes some kind of sense - one I get this sorted Iāll post up my findings in the Heating Boilerplate thread as this may be quite a funky way to get multi-zone heating working nicely.