I have made a script to turn on the light when it get dark in the room. - See code below.
But when I compare the lux value, I do not always get a number. Only if the lux value has changed since last entry. otherwise i get "Nil".
The Lux Sensor is a Xiaomi Motion Sensor with lux. it report the lux value every 5 min.
eg if i compare.
17:55 - lux = 34
18:00 - lux = 30 domoticz.devices('Stue').lux will be "30"
18:05 - lux = 19 domoticz.devices('Stue').lux will be "19"
18:10 - lux = 0 domoticz.devices('Stue').lux will be "0"
18:15 - lux = 0 domoticz.devices('Stue').lux will be "Nil"
18:20 - lux = 0 domoticz.devices('Stue').lux will be "Nil"
Am I doing something wrong..? if i look in the log under the device it show the right value.
I know i can save the value to a variable only if it a valid number and use that for the compair, but it seems a bit like a work around..
Code: Select all
--- Turn on the light when it get dark.
if (device.name == 'Pir - koekken') and (device.state == 'On') and (domoticz.time.hour <= 8 and domoticz.time.hour >= 6) and (domoticz.devices('Switch - Lampe skaenk').state == 'Off') and (domoticz.devices('Stue').lux <= 20) then
domoticz.devices('Switch - Lampe skaenk').dimTo(70)
print('Lampe på skæmk tændes om morgenen')
end