Auto-off heating when max-temp reached?

So, I have five TRV things, where each has an item for the desired term (TRV_Lounge_Target_Temp, TRV_Kitchen_Target_Temp, …).

Each TRV has a current temp item of type Number (TRV_Lounge_Current_Temp, TRV_Kitchen_Current_Temp, …) [well I had to innovate!]

I have a heating controller thing of type Switch (ON/OFF) and item name is HVAC_Switch.

So, I’d like a rule that takes the max value from all of the TRV_Target_Temp and compares this with the corresponding TRV_Current_Temp, and if the target temp has been reached then the HVAC controller is switched OFF otherwise it remains ON, but only for up-to ONE HOUR max, after which the rule turns off the HVAC (aka “it gives up!”).

There’s many ways to cook this broth, I could craft a quick script:

if ( TRV_Lounge_Current_Temp.state >= TRV_Lounge_Target_Temp.state
     and TRV_Kitchen_Current_Temp.state >= TRV_Kitchen_Target_Temp.state ) {


        /* followed by code to disable HVAC switch for an hour , prob a cron rule , not decided */

but not being an Xtend / Java guru, I wondered if someone could provide some magic that would allow the logic to be flexible ,to cater for any future TRVs I might add using the same nomenclatures. So provided I name future TRVs accordingly, this logic would self-adapt?

A teaser for you coding experts!

Here’s single t-stat rule with hysteresis example:

rule "Elutoa temperatuur"
    Item ElutoaSetpoint changed or
    Item ElutoaTemp changed
    var Number cur_temp = ElutoaTemp.state as Number
    var Number setpoint = ElutoaSetpoint.state as Number
    val  Number hysteresis = 0.5

    if (cur_temp < (setpoint - hysteresis)) {
        if (ElutoaRadikas.state != ON) {ElutoaRadikas.sendCommand(ON)}
    else if(cur_temp > setpoint + hysteresis) {
        if (ElutoaRadikas.state != OFF) {ElutoaRadikas.sendCommand(OFF)}

For the hour timer you can do something like this:

var Timer myTimer = null
rule "Motion OFF"
    Item Motion changed from OFF
    if (myTimer === null) {
        if  (Motion.state == ON) {
            myTimer = createTimer(now.plusSeconds(60), [ |
                if (Motion.state == ON){
                //do stuff

Or use the Expire binding to stop the heater after one hour.

That’s a bloody well perfect reply. 101% mate. I will tweak for my t-stat , and test it out. Will come back here when done.

Many thanks :+1:

1 Like

Glad I could help. :smiley:

@tillykeats: I was going to attempt and write it for you, but seems you have a good grip on it. :wink:

Yea pal, just needed a framework, but thanks anyway/again.
p.s. I take it the hysteresis avoids oscillating the boiler and it going into failsafe?