Hello,
I am trying to build a rule to use my light sensors for controlling my roller shutters.
In the end, the roller shutters should close 3/4 if there is direct sunlight for more than 5 minutes.
But now I am stuck right at the beginning, because my condition for detecting direct sunlight does not work.
So this is my light sensor item:
Number:Illuminance LightSensorEast "Helligkeitssensor Osten Helligkeit" { channel="deconz:lightsensor:9e712078:04cf8cdf3c78c9d5010400:lightlux" }
and this is my rule:
var Number LightSensorEastOldValue = -1.0
rule "Update Item LightSensorEast"
when
Item LightSensorEast changed
then
logInfo("LightSensorEast", "LightSensorEast changed to {}", LightSensorEast.state)
logInfo("LightSensorEast", "LightSensorEastOldValue is {}", LightSensorEastOldValue)
//initialize the old value variable, if it is -1.0
if(LightSensorEastOldValue == -1.0)
{
LightSensorEastOldValue = LightSensorEast.state
}
if(LightSensorEastOldValue > 10000 &&
LightSensorEast.state <= 10000)
{
logInfo("LightSensorEast", "Open rollershutter east")
}
if(LightSensorEastOldValue < 50000 &&
LightSensorEast.state >= 50000)
{
logInfo("LightSensorEast", "Close rollershutter east")
}
LightSensorEastOldValue = LightSensorEast.state
end
I see log messages when the light sensor changes e.g.
2020-06-26 06:50:16.964 [INFO ] [arthome.model.script.LightSensorEast] - LightSensorEast changed to 50489 lx
2020-06-26 06:50:16.971 [INFO ] [arthome.model.script.LightSensorEast] - LightSensorEastOldValue is 41172 lx
But why is there no message “Close rollershutter east” in the log? It should have entered the if-block, because the new value is bigger then 50000 and the old value is less than 50000, right?
What am I missing?
Any help appreciated!
Regards
Bernd