have a air quality internet xml source in my country I would like to add in domoticz for my city.
The XML looks like this:
Code: Select all
<!-- -->
<root>
<node>
<dateIndice>2017-01-03</dateIndice>
<agglomerationCodeInsee>97209</agglomerationCodeInsee>
<agglomeration>FORT-DE-FRANCE</agglomeration>
<valeurIndice>3</valeurIndice>
<SousIndiceO3>2</SousIndiceO3>
<SousIndiceNO2>2</SousIndiceNO2>
<SousIndicePM10>3</SousIndicePM10>
<SousIndiceSO2/><Commentaire/>
<sourceAASQA>http://www.lcsqa.org/aasqa/code/39</sourceAASQA>
</node>
<node>
<dateIndice>2017-01-03</dateIndice>
<agglomerationCodeInsee>76540</agglomerationCodeInsee>
<agglomeration>ROUEN</agglomeration>
<valeurIndice>5</valeurIndice>
<SousIndiceO3>1</SousIndiceO3>
<SousIndiceNO2>2</SousIndiceNO2>
<SousIndicePM10>5</SousIndicePM10>
<SousIndiceSO2>1</SousIndiceSO2>
<Commentaire/><sourceAASQA>http://www.lcsqa.org/aasqa/code/25</sourceAASQA>
</node>
...
...
</root>
So on linux I tried:
Code: Select all
$ wget -O test.xml http://www.lcsqa.org/surveillance/indices/prevus/jour/xml/
$ xmllint --xpath '//node[agglomerationCodeInsee=76540]/valeurIndice/text()' test.xml
Code: Select all
5
It looks like this:
Code: Select all
-- ID domoticz
local deviceId = 133
-- Retrieve the request content
s = request['content'];
-- Parse XML values
local iGlobal = domoticz_applyXPath(s,'//node[agglomerationCodeInsee=76540]/valeurIndice/text()')
print('Indice: ' .. iGlobal)
-- Update device
domoticz_updateDevice(deviceId,'',iGlobal)
In domoticz logs:
Code: Select all
2017-01-04 13:24:36.408 CLuaHandler: udevices: Indice: true