Hi,
I have a XML-output, e.g.
<e2servicelist>
<e2service>
<e2servicereference>N/A</e2servicereference>
<e2servicename>N/A</e2servicename>
</e2service>
</e2servicelist>
and searched and read a lot of threads, but was not able to find the fitting solution for me:
Unfortunately the header is send as application/xhtml+xml. I think, that it is not converted to JSON because of this.
If load it via
- platform: rest
resource: 'http://IP/web/subservices'
the value is
<?xml version="1.0" encoding="UTF-8"?><e2servicelist> <e2service> <e2servicereference>N/A</e2servicereference> <e2servicename>N/A</e2servicename> </e2service> </e2servicelist>
Is there any way to get this to work, so I take the data e.g. via
- platform: rest
resource: 'http:/IP/web/subservices'
value_template: '{{ value_json["e2servicereference"] }}'
json_attributes:
- e2servicename
esp. to have one value as state and the other as attribute.
If I get it currently as
- platform: command_line
command: 'curl get "http://IP/web/subservices" 2>&1 | grep -oPm1 "(?<=<e2servicereference>)[^<]+"'
It is working, but is there a way to select two values and put one in the state and the other in an attribute?
If I get/tried this currently via
- platform: scrape
resource: 'http:/IP/web/subservices'
select: 'e2servicereference'
it is working as well, but here the same question with both values, one as state and the other als attribute. And scrape (or - hopefully not - all ways) leave the last state, if e.g. http:/IP/web/subservices is offline. But in this case, I want a 404 or whatever state and not the last successful one. Is this only via scrape and/or hat to customize the behavior?
Thanks a lot in advance, for some hints and information.