Readout Lightsensors in Lua

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Readout Lightsensors in Lua

Post by Toulon7559 »

{The svalue-list of Domoticz shows for the various devices number-strings of defined layout per type of device.}
Readout from a device-string can usually be done by means of otherdevices_svalues[.....]:
for a single value-device

Code: Select all

value = otherdevices_svalues[.....]
for a multiple-value device with elements separated by ;

Code: Select all

value1, value2 = otherdevices_svalues[.....]:match("([^;]+);([^;]+)")
{In the device-list} Lux-devices not only have a number in an element-field, but also a related text for the unit (see example below for a device-list):
{that may also -accidentially- occur in the svalue-list for 'home-made' virtual devices.}
For extraction of values then you could also use a construction like below, which 'differently' looks at the string

Code: Select all

sLux5_string = otherdevices_svalues[SI1145Lux]
sLux5, sLux_txt = sLux5_string:match("(.*)% (.*)")
List of Lux-devices
List of Lux-devices
screenshot-Domoticz_LuxDevices-2020.11.26-14_10_27.png (81.14 KiB) Viewed 310 times
A lot of 'main' device-strings (like temp, hum, barometer and wind) have a dedicated version of 'otherdevices', enabling direct extraction of a specific element from a string with several elements, like examples below

Code: Select all

otherdevices_winddir[WindMeter1]
otherdevices_windspeed[WindMeter1]
otherdevices_windgust[WindMeter1]
otherdevices_uv[SI1145UVI]
For latter an example list of devices.
List of UV-devices
List of UV-devices
screenshot-Domoticz_UVDevices-2020.11.26-14_09_11.png (91.36 KiB) Viewed 310 times
First aspect that surprises, is that Light has no dedicated, easy 'otherdevices' to extract the Lux-value, equivalent to otherdevices_uv:
is a specific reason for this absence? If no specific reason, suggestion to add a variant otherdevices_lux
Second aspect, which puzzles (operating with the example-lists for Lux-devices and UV-devices), is that dependent on the device sometimes you have to choose a different version of 'otherdevices' to get the desired element.
Because all devices look as if 'obeying the format'-rules, what could be reason for that?
Last edited by Toulon7559 on Friday 27 November 2020 19:54, edited 8 times in total.
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
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Readout Lightsensors in Lua

Post by waaren »

Toulon7559 wrote: Thursday 26 November 2020 14:45 Lux-devices not only have a number in an element-field, but also a related text for the unit(see example below for a device-list):
The unit is not a part of the svalue. The svalue contains only a number for Lux type devices
Light has no dedicated, easy 'otherdevices' to extract the Lux-value
For Lux and a number of other device-types that have only 1 numeric value in svalue you can use otherdevices_utility[deviceName])

Or to make it easier; use dzVents and get the Lux without a need to know from which table this value comes.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Readout Lightsensors in Lua

Post by Toulon7559 »

waaren,

You are right that svalues is numbers only:
I confused from Domoticz the device-list with the svalue-list.

Taking into account your response, tried to correct my first message in this thread to reduce risk of confusion:
added some text { }

Any explanation possible for the second aspect?
[No clear coincidence visible related to load or to type of software:
All Raspberries have same Raspian_Buster,
3 Raspberries (for 'Production') have stable Domoticz, others have latest beta-Domoticz,
2 Raspberries (for 'Production') have many scripts to run (most lua, some python, some dzVents, few PHP), others not]
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.
Post Reply

Who is online

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