Hi
I’m trying to access some values from a remote xml. And the XPath expression is not working with the predefined date parameter.
These are my files:
Number probLluvia "[%d]" {http="<[http://www.aemet.es/xml/municipios/localidad_12040.xml:100000:XPATH(/root/prediccion/dia[4]/prob_precipitacion[@periodo='00-24'])]"}
Number probLluviaX "[%d]" {http="<[http://www.aemet.es/xml/municipios/localidad_12040.xml:15000:XPATH(/root/prediccion/dia[@fecha='%1$tY-%1$tm-%1$td']/prob_precipitacion[@periodo='00-24'])]"}
Number probLluviaXTest "%1$tY-%1$tm-%1$td [%s]" {http="<[http://www.aemet.es/xml/municipios/localidad_12040.xml:15000:XPATH(/root/prediccion/dia[@fecha='2018-01-02']/prob_precipitacion[@periodo='00-24'])]"}
The second one is the one I want to make work, the other two are tests to check my syntax.
In the first one it works but, i have to access by index which is not reliable because could be another day data.
In the the third item, I access harcoding the date and it also work.
I print logs on the state of these item in a rule:
logInfo("lluvia","Lluvia: " + probLluvia.state.toString)
logInfo("lluvia","LluviaFecha: " + probLluviaX.state.toString)
logInfo("lluvia","LluviaFechaTest: " + probLluviaXTest.state.toString)
and these are the logs I get:
[INFO ] [clipse.smarthome.model.script.lluvia] - Lluvia: 5
[INFO ] [clipse.smarthome.model.script.lluvia] - LluviaFecha: NULL
[INFO ] [clipse.smarthome.model.script.lluvia] - LluviaFechaTest: 5
Any ideas what I’m doing wrong? Any help would be apreciated.
Thank you
*(If you test this in the future be sure to change the hardcoded values)