I am looking for Status (in this case “Playing”), Artist, Name (which is song title) and PositionDisplay (which is minutes/seconds played of total minutes and seconds). But I have been hitting a brick wall for an hour, I just can’t understand how to configure this. Can somebody please help me out?
Thanks for answering! I had to remove XML_attributes, because that is not a valid option for the REST sensor. But still the sensors are shown as “unknown”. I get this in the log:
Logger: homeassistant.helpers.template
Kilde: helpers/template.py:2651
Førs oppstått: 21:13:24 (8 hendelser)
Sist logget: 21:16:54
Template variable warning: 'dict object' has no attribute 'Status' when rendering '{{ value_json.Response.Status }}'
So it seems it doesn’t see that. And I see in the REST sensor that it should convert it, but I don’t understand the specs:
A list of keys to extract values from a JSON dictionary result and then set as sensor attributes. If the endpoint returns XML with the text/xml, application/xml or application/xhtml+xml content type, it will automatically be converted to JSON according to this specification
Edit: I found a double value_template in the first sensor, one with OK and one with {{ value_json.Response.Status }} but removing the OK one didn’t help.
Hmmm … I wish I could help but I don’t have the time to setup a webserver that reply the same XML now.
Sorry for the mistakes, copy/paste from multiple sensors was not an easy task
Thanks, I of course understand that you don’t have time to setup a webserver for me. If you need to see the info, it would be one easy install of the trial version of J.River Media Center 32, and you’ll have the same server (you’d just need to set up Tools/Options/Media Network/Use Media Network, and then the menu 7 points below that, Advanced, TCP Port to 16000, that would make an identical setup). And I’m not in a hurry, I can’t solve this myself anyway.
Ok, first, as your XML is more than 255 characters, the rest sensor will not work as such, sorry, it will need some remorking.
Scrape could work but you’ll end with selectors like #folder0 > div.opened > div:nth-child(15) > span:nth-child(2) to pickup the Artist which I don’t find very convenient and maintanable.
rest_command:
get_playback_info:
url: "http://192.168.3.1:16000/mcws/v1/Playback/Info?Zone=-1"
method: GET
Then, do an automation to fill various input_text (create them via the UI), I did for one but you can do all the others by adding a new action to the list
That’s an inelegant solution when REST sensors can read XML. Here’s a RESTful integration version that directly populates sensors and does not require regex:
You’d get that error if you omitted the value_template, as it would try to store the entire response in the sensor state, which is over the limit.
The RESTful integration allows multiple sensors to be populated from a single call to the resource, without needing the entire response to fit in 255 characters.