Rule to change heating based on presence

Hello,

i have a Rule to change my heating temperature based on my presence respectively by setting a state manual.

I have a OH 1.8 System

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

rule “Urlaub AN”

when
Item Urlaub changed from OFF to ON

then
sendCommand(Temp_Thermostat_modus_Manu, ON)
sendCommand(gThermostatSoll, 18)
sendCommand(gHeizungBadSoll, 15)
sendCommand(gHeizungGastSoll,15)
sendCommand(gHeizungKindSoll,15)
sendCommand(gHeizungSZSoll, 15)

if( Heimkino_Power.state==ON ) {
    sendCommand(Heimkino_Power, OFF)
}

end

rule “Urlaub AUS”

when
Item Urlaub changed from ON to OFF

then
if(( owmTemperatur.state) < 20 ) {
sendCommand(gThermostatSoll, 18)
sendCommand(Temp_Thermostat_modus_Auto, ON)

} else { 
    sendCommand(gThermostatSoll, 22)
    sendCommand(Temp_Thermostat_modus_Auto, ON)
    
}
sendCommand(gHeizungBadSoll, 15)
sendCommand(gHeizungGastSoll, 15)
sendCommand(gHeizungKindSoll, 15)
sendCommand(gHeizungSZSoll, 15)
if( Heimkino_Power.state==OFF ) {
    sendCommand(Heimkino_Power, ON)
}

end

It works fine, but i want to update the state of Temp_Thermostat_modus_Auto and Manu … my switch said Manu and Auto together, the temperature was set, but the Modus always on Automatik or Manuel.

How can i set the Mode and update the status to Automatic and the Switch to ON and the Switch for Manu is set to off?

I have a Homematic CCU2

L0veb0x

rule "change mode"
when
    Item Temp_Thermostat_modus_Auto changed or
    Item Temp_thermostat_modus_Manu changed
then
    if (triggeringItem.name.toString = "Temp_Thermostat_modus_Auto") {
        if (triggeringItem.state.toString == "ON") {
            Temp_thermostat_modus_Manu.sendCommand(OFF)
        } else {
            Temp_thermostat_modus_Manu.sendCommand(ON)
        }
    } else {
        if (triggeringItem.state.toString == "ON") {
            Temp_thermostat_modus_Auto.sendCommand(OFF)
        } else {
            Temp_thermostat_modus_Auto.sendCommand(ON)
        }
    }
end

When Auto receives ON the Manu is set to OFF
and vice versa

1 Like

hi, Vincent
thx it looks so easy … :slight_smile: but …

i add the rule at the end of my existing rule.
When i start the rule this message ist displayed

2018-04-09 20:44:45.495 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘change mode’: org.eclipse.xtext.util.PolymorphicDispatcher$NoSuchMethodException: Couldn’t find method ''assignValue’’ for objects [JvmVoid: (eProxyURI: urlaub.rules#xtextLink::0.2.2.2.0.0.0::0::/2), toString , Temp_Thermostat_modus_Auto, org.eclipse.xtext.xbase.interpreter.impl.DefaultEvaluationContext@1bdce0a, org.eclipse.xtext.util.CancelIndicator$1@6f5a13]

What happened?
The Lights goes off, the Heating Temp set to 18° and the Switch change to manual but the auto switch always on! … If i change it back, the Lights goes ON, The Temp remains at 18° and the switches do not change

Can you say about the error Message?

L0veBox

Sorry I made a stupid typo…

    if (triggeringItem.name.toString == "Temp_Thermostat_modus_Auto") {

== not =

U might want to have a look at this:

1 Like

Hy,
this is a interest link.
I’ll take a look at this

Thx