Readout Lightsensors in Lua
Posted: Thursday 26 November 2020 14:45
{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
for a multiple-value device with elements separated by ;
{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
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
For latter an example list of devices.
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?
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[.....]
Code: Select all
value1, value2 = otherdevices_svalues[.....]:match("([^;]+);([^;]+)")
{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("(.*)% (.*)")
Code: Select all
otherdevices_winddir[WindMeter1]
otherdevices_windspeed[WindMeter1]
otherdevices_windgust[WindMeter1]
otherdevices_uv[SI1145UVI]
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?