mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
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:
parent
0fddaedc12
commit
61c57d4d56
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user