Page 1 of 1
Use LUX with Dzvents
Posted: Sunday 03 March 2019 9:04
by bing69
Need some help with reading a Xiaomi Pir with Lux sensor. Would like to read this and use it in a script but do not know how to handle it. I can not find an example in the manual.
Can someone help me on my way?
Re: Use LUX with Dzvents
Posted: Monday 04 March 2019 20:55
by EddyG
Use the 'device.lua' from the examples/templates and use the lux attribute from
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Re: Use LUX with Dzvents
Posted: Monday 04 March 2019 23:03
by waaren
bing69 wrote: ↑Sunday 03 March 2019 9:04
Need some help with reading a Xiaomi Pir with Lux sensor. Would like to read this and use it in a script but do not know how to handle it. I can not find an example in the manual.
Can someone help me on my way?
Try this.
Code: Select all
return {
on = { devices = { "Xiaomi Pir with Lux sensor" }}, -- change to the name you gave this device
execute = function(dz, item)
local Lux = item.lux
local Lights = dz.devices("Your light")
local maxLux = 30 -- lights will only switched On if lux is less than this
local maxSeconds = 300 -- Lights will stay on for this amount of seconds after PIR state changed to Off
if Lux < maxLux and item.state == "On" then
Lights.cancelQueuedCommands()
Lights.switchOn().checkFirst()
elseif item.state == "Off" and Lights.state == "On" then
Lights.switchOff().afterSec(maxSeconds)
end
end
}
Re: Use LUX with Dzvents
Posted: Tuesday 05 March 2019 9:28
by bing69
I already did. I found only this info:
Lux sensor
lux: Number. Lux level for light sensors.
updateLux(lux): Function. Supports command options.
Re: Use LUX with Dzvents
Posted: Tuesday 05 March 2019 9:30
by bing69
waaren wrote: ↑Monday 04 March 2019 23:03
bing69 wrote: ↑Sunday 03 March 2019 9:04
Need some help with reading a Xiaomi Pir with Lux sensor. Would like to read this and use it in a script but do not know how to handle it. I can not find an example in the manual.
Can someone help me on my way?
Try this.
Code: Select all
return {
on = { devices = { "Xiaomi Pir with Lux sensor" }}, -- change to the name you gave this device
execute = function(dz, item)
local Lux = item.lux
local Lights = dz.devices("Your light")
local maxLux = 30 -- lights will only switched On if lux is less than this
local maxSeconds = 300 -- Lights will stay on for this amount of seconds after PIR state changed to Off
if Lux < maxLux and item.state == "On" then
Lights.cancelQueuedCommands()
Lights.switchOn().checkFirst()
elseif item.state == "Off" and Lights.state == "On" then
Lights.switchOff().afterSec(maxSeconds)
end
end
}
Thanks, for now i solved with a dummy (Lux) in Blocky and further in Dzvents.