From 61c57d4d563a2c55bc42e0631098ded0e3857ab8 Mon Sep 17 00:00:00 2001 From: emufan Date: Fri, 18 Dec 2020 21:27:12 +0100 Subject: [PATCH] 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 Co-authored-by: J. Nick Koston --- homeassistant/components/rest/sensor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/rest/sensor.py b/homeassistant/components/rest/sensor.py index 51d9ec20472..85d79b6b331 100644 --- a/homeassistant/components/rest/sensor.py +++ b/homeassistant/components/rest/sensor.py @@ -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))