hobaka
(hobaka)
April 8, 2021, 12:23pm
1
Platform information:
Hardware: Raspi 4
OS: OH3, http in Docker, Linux
Binding HTTP installed
Dear experts,
i need a little help for configuration via OH3-GUI reading xml-file.
This is my configuration:
UID: http:url:c94a0df2ed
label: 001-HTL_STE_XML
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: true
baseURL: http://:40080/
refresh: 30
commandMethod: GET
contentType: text/xml
timeout: 3000
bufferSize: 2048
channels:
id: XML_Status
channelTypeUID: http:string
label: XML-Status
description: “”
configuration:
mode: READONLY
stateExtension: HBData_Test.xml
stateTransformation: XPath://dataroot/AbfReservation/Status
item:
426_HTL_STE_XML
State Description with 0=xy, 1=zx, 2=ss
Channel Links to 001-HTL_STE_XM (String, Point)
XML-File: HBData_Test.xml
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2021-03-24T16:25:02">
<AbfReservation>
<Anreise>2021-03-24T00:00:00</Anreise>
<Abreise>2021-03-26T00:00:00</Abreise>
<ZNr>426</ZNr>
<Name>dispo-Tf Education GmbH</Name>
<ERWACHSEN>1</ERWACHSEN>
<Status>3</Status>
<STYLE>1</STYLE>
<GASTNR>119059</GASTNR>
<Uhrzeit>16:25:02</Uhrzeit>
</AbfReservation>
</dataroot>
With webvievw-item it is possible present the file HBData_tes.xml
I get no value from HBData_test.xml and no info in event.log.
rossko57
(Rossko57)
April 8, 2021, 1:54pm
2
That looks suspect (not XPATH) does your openhab.log have anything to say about it?
hobaka
(hobaka)
April 8, 2021, 2:22pm
3
yes, I found an error:
[WARN ] [.transform.SingleValueTransformation] - Executing transformation ChannelStateTransformation{pattern=’//dataroot/AbfReservation/Status’, serviceName=‘XPATH’} failed: transformation throws exceptions
also i checked the xml with XPath Tester / Evaluator; the result is
<Status>3</Status>
hobaka
(hobaka)
April 11, 2021, 8:41am
4
Hello,
no more tips or discussion about this problem here?
what means: transformation throws exceptions
rossko57
(Rossko57)
April 12, 2021, 11:25pm
5
“Something went wrong”. It’s not very helpful to us.
When experimenting with transformations, I find it useful to set up a little rule to check and test things.
So I tried with your data -
val rawxml='<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2021-03-24T16:25:02">
<AbfReservation>
<Anreise>2021-03-24T00:00:00</Anreise>
<Abreise>2021-03-26T00:00:00</Abreise>
<ZNr>426</ZNr>
<Name>dispo-Tf Education GmbH</Name>
<ERWACHSEN>1</ERWACHSEN>
<Status>3</Status>
<STYLE>1</STYLE>
<GASTNR>119059</GASTNR>
<Uhrzeit>16:25:02</Uhrzeit>
</AbfReservation>
</dataroot>'
var results = transform("XPATH", "//dataroot/AbfReservation/Status", rawxml)
logInfo("test", " simple path " + results)
and got the result
2021-04-13 00:16:47.268 [INFO ] [.eclipse.smarthome.model.script.test] - simple path 3
so it looks like your parameters are good.
What’s gone wrong then?
Maybe you don’t get back the XML that you expected.
Set up another temporary string type channel on your HTML Thing, link it to a String type Item and examine the whole message.
Your baseURL looks suspect to me.
hobaka
(hobaka)
April 13, 2021, 2:43pm
6
Next try and error:
Without the “stateTransformation: XPath://dataroot/AbfReservation/Status” i get the hole XML-File to string item.
rossko57
(Rossko57)
April 13, 2021, 3:08pm
7
Yes, that was the whole idea of making a temporary String Item, so that you can check the message.
What is the error please?
hobaka
(hobaka)
April 13, 2021, 3:28pm
8
now i’m edit the xml-file string by string … and the state is correct!!
some special characters within the file… ???
rossko57
(Rossko57)
April 13, 2021, 3:46pm
9
I don’t understand what you are doing. Why not test your XPATH on the whole string in a rule, like my test.
1 Like