I can only guess, but I think you need to convert the state of illumination item to a number ( add: “as Decimal”) in order to make it comparable to the number.
I would also put the two logInfo in the else part into the curly brackets.
thanks a lot for your hint! I wasn’t aware that sting item values are not directly comparable to numbers.
this one is still driving me nuts and a bit more of your help would be appreciated
rule "Light on, if too less daylight"
when
Item GF_Stairwell_Sensor_Licht changed
then
val hue = (GF_Stairwell_Sensor_Licht.state as DecimalType).intValue
logInfo("Lights_rule","Presence: {} Abwesend: {} Tag: {}",Presence.state, Abwesend.state, Tag.state)
if(Presence.state == ON && Abwesend.state == OFF && Tag.state == ON) {
logInfo("Lights_rule","GF_Stairwell_Sensor_Licht: {}", hue)
if(hue <= 11000) {
WZL.sendCommand(ON)
GF_Stairwell_Surface3.sendCommand(80)
logInfo("Lights_rule","Light goes on. WZL: {}" + WZL.state)
}
else if(hue > 11000 && WZL.state == ON) {
GF_Stairwell_Surface3.sendCommand(0)
WZL.sendCommand(OFF)
logInfo("Lights_rule","more daylight, lamp off. WZL: {}", WZL.state)
}
}
end
You had several bugs in your rule, curly brackets at the wrong place and wrong usage of logInfo(). Although it’s possible to build a string and simply log this, you would have to use Item.state.toString. You would have to use additional +" "+ spaces to get a nice output. logInfo() is defined as logInfo(String,String) where the former is the logger name and the latter the text to log. If using "Log Message {}",var there is no need to convert var to string (aside from special vars like dateTime)
It’s more appropriate to split the if clause to the general (presence,abwesend,tag) and the more special two clauses (Sensor_Licht and WZL).
Thanks a lot for your valuable help on the rule but most importantly, thanks for the guidance on the wrong usage of sendCommand & logInfo - this is extreemly helpfull!