i am struggling a bit with a script am upgrading from 2 to 4 it worked in 2 but cant get this right
2024-11-20 12:08:16.177 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘14f53ef7d9’ failed: val Number temp_Offset = 0.1
val Number temp_Offset1 = 0.5
var Number house_heat = house_temp_SP.state as Number
var Number heat_setpoint.state as Number
if (house_heat <= (heat_setpoint - temp_Offset)) {
Central_Heating_Relay.sendCommand(ON)
} else if (house_heat >= (heat_setpoint + temp_Offset1)) {
Central_Heating_Relay.sendCommand(OFF)
}
val Number temp_Offset = 0.1
val Number temp_Offset1 = 0.5
var Number house_heat = house_temp_SP.state as Number
var Number heat_setpoint.state as Number
if (house_heat <= (heat_setpoint - temp_Offset)) {
Central_Heating_Relay.sendCommand(ON)
} else if (house_heat >= (heat_setpoint + temp_Offset1)) {
Central_Heating_Relay.sendCommand(OFF)
}
val Number tempNeg = 0.1
val Number tempPos = 0.5
val Number tempSet = (heat_setpoint.state as Number).floatValue
val Number tempIs = (house_temp_SP.state as Number).floatValue
var target = Central_Heating_Relay.state
if(tempIs <= tempSet - tempNeg)
target = ON
else if(tempIs >= tempSet + tempPos) {
target = OFF
if(Central_Heating_Relay.state != target)
Central_Heating_Relay.sendCommand(target.toString)
.floatValue → will ensure to cut quantity from a QuantityType state (if Items are of type QuantityTpe - but won’t harm if not)
The detour with target will ensure only to send the command if really necessary.