Hi, just a short question. Cant find any answers that fits.
I have a http binding returning a state which is a XML string.
<status><streamUrl>value</streamUrl></status>
I would like to retrieve the value from the XML within the channel configuration as state tansformation but I can’t find any examples for the XPath transform.
Could someone help me out or point me in the right direction?
Assuming that the xpath string itself is correct I don’t see anything wrong with how you’ve formatted it in the HTTP binding. But I don’t use the HTTP binding so don’t know if there are some quirks.
But pay attention to case. Case matters. Your example XML is streamurl not streamUrl.
Thank you for your time and thoughts. After a restart of openhab it works as expected on the thing and on the item.
On the Item " BluOsNAD_Presets" I have a Metadata state description containing two radio stations as options in the format ‘value = label’:
http://playerservices.streamtheworld.com/api/livestream-redirect/RADIO10.mp3 = Radio 10
http://playerservices.streamtheworld.com/api/livestream-redirect/RADIO538.mp3 = Radio 538
From the UI I have a widget that send command ‘label’ to the Item.
The Items resolved the URL and sends it to the the player using a command url extension. That all works fine, the radio changes stream.
Play?url=%2$s
Backwards, the channel requests the player state XML using the state url extension
Status
And retrieves the current playing streamUrl value using the state transformation
XPATH:/status/streamUrl
The Item resolves the station label matching the option list, and the radio station is visible in the Item (‘Radio 10’ or ‘Radio 538’).
If I place a simple text label and select the Item (graphically), it will display the currently playing radio station (‘Radio 10’ or ‘Radio 538’).
So far so good
I created a custom Widget using the oh-list-item but it keeps displaying ‘UNDEFINED’ or ‘-’ for .state and for .stateDisplay. I tried it several ways but nothing seems to work
Well, yes. The state is the current state of the Item. The displayState is the current state of the Item with the Pattern defined in the State Description applied to it. Neither contains the the list of Options.
again thank you for your patience.
I did not post the full widget code, I only posted that what I thought was relevant. Sorry, I updated the Widget posted earlier.
The configuration of the streaming device works fine (action command) what does not work is read back the status as .stateDescription.
The Thing returns the streamUrl to the Item, the items resolves this into the corresponding label, the label should be displayed (but is not).
I’ve to configure the Pattern for the state description. You mentioned it once with command action. I was focussing on the command action, sorry for that. There are just soooo many options
I’ll look into the pattern configuration.
Thank you for helping me out.
And I see a typo, stateDisplay should be displayState. And now it works as expected.
Even without the configuration of Pattern in the Items state-description, somehow the stateDescription exists if the Pattern is not set (because it’s already a string Item?