Manual override

Hi all there,

I have a rule where my Danfoss Living Connect Z-Wave radiator thermostat is set to a certain value (23 degrees Celsius) at morning between 5AM and 9AM depending on the weather temperature outside.
When the temperature is above 12 degrees Celsius the thermostat is set to 14 degrees Celsius.

That is all working fine, but I’m struggling to manually override this temperature if I want to have a different temperature.

I tried a variable which is set to true or false, but my programming skills are not sophisticated enough to make it work.

I found some posts with examples for manually overriding certain values but cannot adapt those to my rule …

Here is my original rule without the variable:

    import org.openhab.core.library.types.*
    import org.openhab.core.persistence.*
    import org.openhab.model.script.actions.*
    import org.joda.time.*
    
   rule "heating"
    when
        Item Temperature_FIO received update
    then
      if (((((new LocalTime().getLocalMillis()) >= (new LocalTime(5, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(9, 0, 0, 0).getLocalMillis()))) && (Temperature_FIO.state <= 12))) {
        sendCommand(DanLivConnZSet1, 23)
      }
      else {
      sendCommand(DanLivConnZSet1, 14)
       }
    end

Then I tried to manual override that rule with a variable, but that doesn’t work:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*

var boolean TemperatureOverride = false

rule "heating"
when
    Item Temperature_FIO received update
then
  if (((((new LocalTime().getLocalMillis()) >= (new LocalTime(5, 0, 0, 0).getLocalMillis())) && ((new LocalTime().getLocalMillis()) <= (new LocalTime(9, 0, 0, 0).getLocalMillis()))) && (Temperature_FIO.state <= 12) && !TemperatureOverride)) {
    sendCommand(DanLivConnZSet1, 23)
    TemperatureOverride = false
    
  }
  else {
  sendCommand(DanLivConnZSet1, 14)
  TemperatureOverride = true
  }
end

My items are:

    Number    DanLivConnZSet1    "Heizung Bad [%.1f °C]"    <heating>    (gTest)        { zwave="8:command=thermostat_setpoint,setpoint_type=1,setpoint_scale=0" }

Number    Temperature_FIO    "Temperatur [%.0f °C]"    <temperature>    (gTest)        { weather="locationId=home_fio, type=temperature, property=current" }

sitemap setpoint for manually set the temperature:

Setpoint item=DanLivConnZSet1 minValue=4 maxValue=30 step=1

Any hints in the right direction?

Thx in advance

In you override example, I think your && clauses are imbalanced in attempt to exit each clause at the same paren level

overall IF should be contained in paren level 1
each clause separated by && should be contained in paren level 2
each sub element in a clause should be contained in lower paren levels

In your override example:
clause 1 ends (ie hits the &&) at paren level 3
clause 2 ends at paren level 2
clause 3 ends at paren level 2
clause 4 ends at paren level 1

if 
 (1  
    (2  (3  (4  (5
           new LocalTime().getLocalMillis()
        )4
         >= 
       (5
           new LocalTime(5, 0, 0, 0).getLocalMillis()
        )4  )3 

   && 

   (4 (5
          new LocalTime().getLocalMillis()
       ) 4
       <= 
       (5
          new LocalTime(9, 0, 0, 0).getLocalMillis()
        ) 4 ) 3 ) 2

  && 

 (3
   Temperature_FIO.state <= 12
  ) 2

  && 

  !TemperatureOverride
 )1  
) 0
{
...  }
</pre

Thanks. It was the first time I used the rule designer in habmin2, so maybe I did something wrong …
After implementing your suggested changes I opened the rule in the openhab designer and realized that there was an error with new LocalTime().getLocalMillis(), so I started from scratch and it looks like it’s working although it may be bad programming:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*

var boolean TemperatureOverride = false

rule "heating"
when
    Item Temperature_FIO received update
then
  if (((now.getHourOfDay() >= 5) && (Temperature_FIO.state <=12) && !TemperatureOverride) && ((now.getHourOfDay() <= 9) && (Temperature_FIO.state <=12) && !TemperatureOverride)) {
        sendCommand(DanLivConnZSet1, 23)
            }
  else if (!TemperatureOverride) {
  sendCommand(DanLivConnZSet1, 14)
  TemperatureOverride = true
  }
end

rule "reset variable"
when
Time cron "0 0 3 ? * *"
then
TemperatureOverride = false
end

So if anyone has a suggestion to do it more professional feel free to answer :grinning:

Hi @sihui. I looked at getting these radiator thermostat heads, but for a number of reasons (2 major technical ones), I threw them out the window as a worthwhile possible solution. Here’s why… noting that my memory may be wrong, and also the products themselves, as well as the firmware has been evolving since their initial release.

  1. There is no way to know the actual room temperature - the TRV does its thing regulating, but you cannot track, alarm, measure the room temperature which controls the heaters.
  2. You cannot remotely change a setpoint; only remotely change/engage a mode (Day, Night, Eco, etc.)

Point #2 is what may be holding you back… something to look into. It is my understanding that the Honeywell proprietary controller can do this, but not the open Z-wave parts.

If this is the case, you may choose to set the Away/Eco modes at the temperature that you want, and then simply use your rule to change the modes.

[quote=“geva, post:4, topic:4009, full:true”]
There is no way to know the actual room temperature[/quote]

I agree. But I think it could be technically very complicated to measure the room temperature in such a near distance to the radiator.

[quote=“geva, post:4, topic:4009, full:true”]
You cannot remotely change a setpoint; only remotely change/engage a mode (Day, Night, Eco, etc.) [/quote]

I disagree. I can change the setpoint without any problems, but don’t have any access to different modes. Maybe there are different hardware versions or firmwares (mine is 2.51) available.

Actually the thermostat is working quite good, I just don’t have the knowledge to write a better rule …

I completely agree that this isn’t an accurate way/place to measure the room temperature… however if the heating is being controlled from this reading, then it makes sense to watch it. For example, in my house, the placement of the thermostat incurs a varying difference with the actual room temperature.

Regardless of how correct it is, monitoring can alert for things like temperature progression, rate of change, etc.

Cool! This is very good to know. I looked at these over 2 years ago, and at that time they were making relatively major firmware changes due to customers pushing back about the limited functionality of their “open” Z-Wave products.