Because I do not have a light sensor, I wrote a script to detect if the snapshot taken from the camera is too small, meaning the image is almost black. If this is true, different scenes can run (like turn infrared on camera on, turn on a virtual switch, …). Of course the values need to be changed according with the camera snapshot path and the size of the picture during dust, day and night. Hope it helps.
[code]–get snapshot
os.execute(“curl -o /tmp/log/cmh/snap.jpg http://user:pass@ip/tmpfs/snap.jpg”)
local snapfile = ‘/var/log/cmh/snap.jpg’
local minfilesize = 10000
local DEVICE_ID = xyz
– small file means black image
local outf = io.open(snapfile , ‘a’)
local filesize = outf:seek(“end”)
outf:close()
luup.log("snap.jpg file size: "… filesize)
if (filesize < minfilesize) then
local status = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”, “Status”, DEVICE_ID)
luup.log("low light: "… status)
if(status==“0”)then
– luup.log(“will set low light virtual switch on”)
return true
else
– luup.log(“low light virtual switch already off”)
return false
end
else
return false
end[/code]