Hey guys, I’m struggling with getting a rule to work. The issue pertains to the ‘heating_time’ value, which is not being picked up below the ‘if/else’ part. The ‘logError’ part is executed just fine. If I place heating_time outside if/else, the script works as well…
My script:
rule "setpoint changed"
when
Item thermostat_setpoint changed
then
var setpoint = thermostat_setpoint.state as Number
var current_temp = tempsensor_01_temperature.state as Number
var delta_temp = setpoint - current_temp
var current_time = now.millis as Number
var time_on = thermostat_time_on.state as Number
var time_off = thermostat_time_off.state as Number
var delta_time_off = ( current_time - (time_off) ) / 1000 / 60
if(delta_time_off > 30){
logError("TEST", "greater than 30")
var heating_time = delta_temp / 0.086
}else{
logError("TEST", "smaller than 30")
var heating_time = delta_temp / 0.129
}
if(setpoint >= current_temp){
if(thermostat_state.state == OFF){
thermostat_state.sendCommand(ON)
thermostat_heating_time.sendCommand(heating_time)
thermostat_time_on.sendCommand(current_time)
thermostat_time_off.postUpdate(delta_time_off)
thermostat_timer.sendCommand(ON)
}else{
thermostat_heating_time.sendCommand(heating_time)
thermostat_timer.sendCommand(ON)
}
}else{
thermostat_state.sendCommand(OFF)
thermostat_heating_time.sendCommand(0)
thermostat_time_on.sendCommand(0)
thermostat_time_off.sendCommand(current_time)
thermostat_timer.sendCommand(OFF)
}
end
The ‘ERROR’
Blockquote
2020-01-04 14:02:45.121 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘thermostaat.rules’, using it anyway:
The value of the local variable time_on is not used
The value of the local variable heating_time is not used
The value of the local variable heating_time is not used
Proof that stuff inside the if/else are being executed;
Blockquote
==> /var/log/openhab2/openhab.log <==
2020-01-04 14:03:09.607 [ERROR] [.eclipse.smarthome.model.script.TEST] - greater than 30