Page 1 of 1

Reading lux sensor

Posted: Monday 12 September 2022 14:21
by pkelderman
Does somebody know how to retrieve the number of lumen/lux from a lux sensor? Thanks at forehand! I want to use it in a lua-script.....

Re: Reading lux sensor

Posted: Monday 12 September 2022 14:48
by Toulon7559
Which type/model of lux-sensor?

Re: Reading lux sensor

Posted: Monday 12 September 2022 18:12
by madpatrick
In Dzvents it is like this

Code: Select all

execute = function(dz)
local lux           = dz.devices(454).lux
if lux = 100 then .....
454 is of course your device number

Re: Reading lux sensor

Posted: Monday 12 September 2022 19:03
by pkelderman
I'm using a ZW100 Multisensor 6+ from Aeon Labs; the same brand as my controller, that's a ZW090 Z-stick Gen5 from Aeon labs. Need more info? Please tell me?

Re: Reading lux sensor

Posted: Monday 12 September 2022 19:11
by pkelderman
I tried;
current = otherdevices_humidity[TempEnVocht]
current = devices(Lichtsterkte)

the first one works, the second gives:

2022-09-12 19:09:00.140 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_PIRs.lua: /home/pi/domoticz/scripts/lua/script_time_PIRs.lua:29: attempt to call a nil value (global 'devices')

Re: Reading lux sensor

Posted: Monday 12 September 2022 19:17
by madpatrick
pkelderman wrote: Monday 12 September 2022 19:11 I tried;
current = otherdevices_humidity[TempEnVocht]
current = devices(Lichtsterkte)

the first one works, the second gives:

2022-09-12 19:09:00.140 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_PIRs.lua: /home/pi/domoticz/scripts/lua/script_time_PIRs.lua:29: attempt to call a nil value (global 'devices')
You need to add .lux after device name

Code: Select all

 current = devices(Lichtsterkte).lux

Re: Reading lux sensor

Posted: Tuesday 13 September 2022 14:38
by pkelderman
I have tried:
local Lichtsterkte = 'Lichtsterkte'
current = devices(Lichtsterkte).lux
print(current)

The log says:
2022-09-13 14:35:00.160 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_PIRs.lua: /home/pi/domoticz/scripts/lua/script_time_PIRs.lua:34: attempt to call a nil value (global 'devices')

Re: Reading lux sensor

Posted: Tuesday 13 September 2022 14:54
by madpatrick
pkelderman wrote: Tuesday 13 September 2022 14:38 I have tried:
local Lichtsterkte = 'Lichtsterkte'
current = devices(Lichtsterkte).lux
print(current)

The log says:
2022-09-13 14:35:00.160 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_PIRs.lua: /home/pi/domoticz/scripts/lua/script_time_PIRs.lua:34: attempt to call a nil value (global 'devices')
Can you post the complete script.
I'm aan NoNo on Lua and little bit better in Dvents, but maybe i can assist in getting you in the right direction

Re: Reading lux sensor

Posted: Tuesday 13 September 2022 16:51
by azonneveld
Try:

current = tonumber(otherdevices['Lichtsterkte'])

Then don't use:
if current==100 then

But use f.i.
if current >90 and current <110 then

Chances are the value of 100 is skipped due to the refresh interval.

Re: Reading lux sensor

Posted: Tuesday 13 September 2022 17:17
by willemd
madpatrick wrote: Monday 12 September 2022 19:17
pkelderman wrote: Monday 12 September 2022 19:11 I tried;
current = otherdevices_humidity[TempEnVocht]
current = devices(Lichtsterkte)

the first one works, the second gives:

2022-09-12 19:09:00.140 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_PIRs.lua: /home/pi/domoticz/scripts/lua/script_time_PIRs.lua:29: attempt to call a nil value (global 'devices')
You need to add .lux after device name

Code: Select all

 current = devices(Lichtsterkte).lux
And "dz.devices" instead of just "devices"

Re: Reading lux sensor

Posted: Tuesday 13 September 2022 17:47
by jvdz
willemd wrote: Tuesday 13 September 2022 17:17 And "dz.devices" instead of just "devices"
Think this is a regular LUA time script looking at the script path, so otherdevices is the arrayname to use!
Jos

Re: Reading lux sensor

Posted: Friday 16 September 2022 14:36
by pkelderman
@ asonneveld

I tried next solution:

current = tonumber(otherdevices['Lichtsterkte'])
print(current)

the result:

39

Wow it works! Thanks a lot!