Reading lux sensor

Moderator: leecollings

Post Reply
pkelderman
Posts: 28
Joined: Monday 19 July 2021 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Hellevoetsluis (NL)
Contact:

Reading lux sensor

Post 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.....
Toulon7559
Posts: 858
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Reading lux sensor

Post by Toulon7559 »

Which type/model of lux-sensor?
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Reading lux sensor

Post 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
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
pkelderman
Posts: 28
Joined: Monday 19 July 2021 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Hellevoetsluis (NL)
Contact:

Re: Reading lux sensor

Post 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?
Last edited by pkelderman on Monday 12 September 2022 19:12, edited 2 times in total.
pkelderman
Posts: 28
Joined: Monday 19 July 2021 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Hellevoetsluis (NL)
Contact:

Re: Reading lux sensor

Post 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')
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Reading lux sensor

Post 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
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
pkelderman
Posts: 28
Joined: Monday 19 July 2021 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Hellevoetsluis (NL)
Contact:

Re: Reading lux sensor

Post 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')
User avatar
madpatrick
Posts: 667
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: Reading lux sensor

Post 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
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
azonneveld
Posts: 160
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: Reading lux sensor

Post 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.
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
willemd
Posts: 649
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Reading lux sensor

Post 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"
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Reading lux sensor

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
pkelderman
Posts: 28
Joined: Monday 19 July 2021 11:17
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Hellevoetsluis (NL)
Contact:

Re: Reading lux sensor

Post by pkelderman »

@ asonneveld

I tried next solution:

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

the result:

39

Wow it works! Thanks a lot!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest