OH3 XPath

The contents of the file

http://client1:client1@192.168.0.167:83/api.html?part=redstats&label=smr

I want to parse is

 <?xml version="1.0" encoding="UTF-8"?>
 <os version="1uild r11643" revision="11643" starttime="2021-01-12T09:25:12+0100" uptime="4570" readonly="0">
	<reader label="smr" status="CARDOK" cadid="123">
	</reader>
 </os>

I want to check whether the status of reader is CARDOK.

According to OH3 XPath - #3 by garyfree
I created in Main a thing named URL1 with base url

http://user:pw@192.168.0.167/api.html?part=redstats&label=smr

with channel

URLchannel

and State transformation

//reader/@status

as in my OH 2.5 case.

However, this generates an Error:

HANDLER_INITIALIZING_ERROR
The transformation pattern must consist of the type and the pattern separated by a colon

This is where I am stuck.

The transformation field must include the name of the transformation you’re trying to use - openHAB doesn’t try to guess, because there’s too many!

Try:

XPATH://reader/@status

though be warned that I don’t use this transform so don’t know the proper syntax.

Thank you. For clarity, I have described my problem in a more detailed manner.

I will check your proposal this eveneing. Thanks!

@hafniumzinc : Success. Thank you very much for your valuable hint!!!

  1. I had to delete user:pw from base url and transfer this information to the advanced options of the thing. I use basic authentication.
  2. In linked item, I used profile XPATH and Xpath expression //reader/@status. This seems to be equivalent to your proposal “XPATH://reader/@status”.
    Thanks!!

It is fine for me to achieve this by using the new main ui.
Can I achieve this as well using the textual way? Formerly, one line of code was sufficient like this
String MyStatus “Status [%s]” {http="<[http://user:pw@192.168.0.167/api.html?part=redstats&label=smr:30000:XPATH(//reader/@status)]"}

Yes. Show us the YAML for your Thing and we can help convert. But bear in mind that you will have to edit two files: an Items file and a Things file. It’s not all in a single Item line anymore!

This is thing’s code:
UID: http:url:011692df79
label: URL_Easy
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: false
baseURL: http://192.168.0.167:83/api.html?part=redstats&label=em1
password: client1
refresh: 30
commandMethod: GET
timeout: 3000
username: client1
bufferSize: 2048
channels:

  • id: URLEasy
    channelTypeUID: http:string
    label: URL Easy
    description: “”
    configuration:
    stateTransformation: XPATH://reader/@status

Something like the following might work:

Thing http:url:URL_Easy "URL_Easy" [
	baseURL = "http://192.168.0.167:83/api.html?part=redstats&label=em1",
	refresh = "30",
	ignoreSSLErrors = "false",
	username = "client1",
	password = "client1"
]
{
	Channels:
		Type string : URLEasy "URL Easy" [
			mode = "READONLY",
			stateTransformation = "XPATH://reader/@status"
		]
}

Your Item then becomes:

String MyStatus "Status [%s]" { channel="http:url:URL_Easy:URLEasy" }

Thanks!!

First, to double check did you install the Xpath Transformation Service?