Use LUX with Dzvents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Use LUX with Dzvents

Post 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?
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Use LUX with Dzvents

Post by EddyG »

Use the 'device.lua' from the examples/templates and use the lux attribute from https://www.domoticz.com/wiki/DzVents:_ ... _scripting
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Use LUX with Dzvents

Post 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
}     
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Use LUX with Dzvents

Post by bing69 »

EddyG wrote: Monday 04 March 2019 20:55 Use the 'device.lua' from the examples/templates and use the lux attribute from https://www.domoticz.com/wiki/DzVents:_ ... _scripting
I already did. I found only this info:

Lux sensor
lux: Number. Lux level for light sensors.
updateLux(lux): Function. Supports command options.
bing69
Posts: 139
Joined: Thursday 05 June 2014 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: 's-Hertogenbosch, NL
Contact:

Re: Use LUX with Dzvents

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest