Add another xml content type for JSON conversion in RESTful sensor (#44312)

* Update sensor.py

Some xml-result is passed via "application/xhtml+xml" instead of text/xml or application/xml. And then the xml structure is not parsed to json as expected. I changed it locally, but suggest to add thise here as well.

* Update homeassistant/components/rest/sensor.py

Fine for me as well, as it is working this way as well. But I would not see any disadvantage to convert everything, what is possible - a better scrape sensor this way. ;)

Co-authored-by: J. Nick Koston <nick@koston.org>

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
emufan 2020-12-18 21:27:12 +01:00 committed by GitHub
parent 0fddaedc12
commit 61c57d4d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,6 +227,7 @@ class RestSensor(Entity):
if content_type and (
content_type.startswith("text/xml")
or content_type.startswith("application/xml")
or content_type.startswith("application/xhtml+xml")
):
try:
value = json.dumps(xmltodict.parse(value))