I’m trying to read in an http call. Unfortunately without success.
Other http .things work fine.
I call up the file used from a Meteobridge.
Meteobridge enables the integration of various weather stations (e.g. DAVIS) with Live Data as XML.
However, the XML file does not have the same structure as the systems used up to now. As a software beginner, I get stuck.
The Channels part is not true at all.
But I haven’t found a way to read any text element at all.
The XML looks like this (more or fewer lines depending on the application)
To work with XPATH it’s important to understand the “parts” of an XML. You basically have elements and attributes. <logger> is an element. Elements have a starting tag and an ending tag (</logger>) and an element can contain attributes or other elements.
An attribute is a property on an element. temp="17.0" is an attribute on the TH element.
Thanks for your tip.
I have already tried various versions, unfortunately without success.
I also tried the following channel (probably corresponds to your suggestion):
Type string : weather_th "Weather_TH" [ stateTransformation="XPATH:/logger/TH/@temp/text()", mode="READONLY" ]
my Openhab.log acknowledges this with:
…Creating request for ‘xxx:yyy@192.168.188.38/cgi-bin/livedataxml.cgi’ failed: unknown protocol: meteobridge
Access to the address is not criticized.
I’m looking for the bug in the structure of the channel.
The structure of the Meteobridge.XML file seems special to me.
In test files, the structure is referred to as “JSON valid in JavaScript”.
Am I making a mistake?
later I wanted to read in each line as text in order to then separate and interpret each element.
But I couldn’t read the single line either …
Do you have another tip for me?
I am grateful for any suggestion.
Greetings, Urs
I do not support Things in text files so if the problem isn’t the XPATH then I have no other suggestions.
As far as the XPATH is concerned though, I’m not certain the text() is needed at all and it might be causing problems at worse. I don’t know if it will treat the “17.0” as a text node or not. text() does not mean “give me the value as text”, it means “only match nodes that are text nodes, ignoring all other node types.”
The example you posted is definitely XML, not JSON.
To double check: create a String Channel without the stateTransformation parameter to make sure that you’re receiving the full XML that you expect.
I’m sure it will fail, because this:
isn’t valid, as your log has told you.
You’re trying to use the HTTP Binding, so you need to supply a valid URL - one that would work in a browser (as you’re using GET). So, one that starts with http:// or https://