Reading data by lua from (remote) virtual devices
Posted: Monday 14 November 2022 19:34
Application of data of virtual devices requires extraction of such data.
Not always easy & consistent as discussed here.
More complicated when the virtual device is resident in another/remote Domoticz-instance:
Simple solution is duplication of the device in the 'local' Domoticz-instance, but is an extra step & dependency in the chain, to be avoided.
Testing at CLI should give same results as during normal runtime, unlike constructions using 'otherdevices_svalues'.
The following setup is a derivative from the read-out by lua-script of DarkSky-info, giving combined, practical solution for the 3 aspects mentioned above.
The setup described in this message has been triggered by the need to get hold of data from an Ecowitt GW1000 which collects data from various sensors.
The setup consists of 2 steps.
The 1st step is reading & decoding of the json-file coming out of the GW1000:
that decoding results in a number of virtual devices according to the API/JSON for Domoticz.
Not further described.
The 2nd step is individually reading those virtual devices and extracting data.
The script below in the spoiler is a feasability demonstration of that 2nd step as a lua-script.
- IPs of the weblinks have to be tuned [by manipulation of the IP probably also a local virtual device can be read]
- RIDs need to be aligned for the configuration
- on purpose the script-block per sensor-type is identical in layout, but for a combination of devices some redundant scriptlines might be removed/disabled
- the use of the output-data is your choice .....
Note
In practise the 1st step of the setup is very similar to the 2nd step, but with realisation through a Python-script.
Not always easy & consistent as discussed here.
More complicated when the virtual device is resident in another/remote Domoticz-instance:
Simple solution is duplication of the device in the 'local' Domoticz-instance, but is an extra step & dependency in the chain, to be avoided.
Testing at CLI should give same results as during normal runtime, unlike constructions using 'otherdevices_svalues'.
The following setup is a derivative from the read-out by lua-script of DarkSky-info, giving combined, practical solution for the 3 aspects mentioned above.
The setup described in this message has been triggered by the need to get hold of data from an Ecowitt GW1000 which collects data from various sensors.
The setup consists of 2 steps.
The 1st step is reading & decoding of the json-file coming out of the GW1000:
that decoding results in a number of virtual devices according to the API/JSON for Domoticz.
Not further described.
The 2nd step is individually reading those virtual devices and extracting data.
The script below in the spoiler is a feasability demonstration of that 2nd step as a lua-script.
- Spoiler: show
- IPs of the weblinks have to be tuned [by manipulation of the IP probably also a local virtual device can be read]
- RIDs need to be aligned for the configuration
- on purpose the script-block per sensor-type is identical in layout, but for a combination of devices some redundant scriptlines might be removed/disabled
- the use of the output-data is your choice .....
Note
In practise the 1st step of the setup is very similar to the 2nd step, but with realisation through a Python-script.