-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing XML with Rest Sensor broken #92836
Comments
Hey there @epenet, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) rest documentation |
Here is output of the {{value_json}} template for both versions: 2023.4.6: 2023.5.x |
Hey @mutasim can you turn on debug logging by setting this in your configuration.yaml file? logger:
default: info
logs:
homeassistant.components.rest: debug There is a debug statement here that will write out the data being returned from your REST endpoint, and another one here. That will confirm how the XML is being converted from JSON. From what its worth though, i cannot reproduce this on v2023.6.0 (dev branch) . I mocked the REST response to be the XML data you provided, and it still gets parsed correctly. I suspect the data being returned from the endpoint may have changed.
|
Hey, Thanks for the follow up. Looks like the data returned differs depending on which version I run. I've swapped out the container but config & endpoint/payload remain the same. 2023.5.2
2023.4.6
For good measure I've uploaded the XML file again that is returned when I access the endpoint in my browser. Thanks for your help. |
I guess the issue is with encoding
|
@mutasim thanks for that, looks like you ran into a bug in the httpx library, which recently got fixed in this PR encode/httpx#2701 I confirmed that fixes the issue, it encodes the URL correctly with their changes |
Taking a closer look at the code over there, I don't think there is an available workaround for this that will cause the I'm not sure when they will do their next official release, but we should bump the version dependency here once they do. |
It would be great if you could test #93396 |
Happy to help test - I'll need some guidance on where I can find/how to build this into a docker image. |
The problem
Parsing an endpoint with the following XML payload:
<cmd status="ok"> <device id="0"> <reg vid="124" tid="heat" v="4" min="0" max="65535"/> </device> </cmd>
using the following template:
value_template: '{{value_json.cmd.device.reg["@v"]}}'
used to correctly extract the 'v' value. Now the sensor shows as 'Unknown'.
What version of Home Assistant Core has the issue?
core-2023.5.0
What was the last working version of Home Assistant Core?
core-2023.4.6
What type of installation are you running?
Home Assistant Container
Integration causing the issue
No response
Link to integration documentation on our website
https://www.home-assistant.io/integrations/sensor.rest/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
XML file attached: getregister.xml.zip
No response
The text was updated successfully, but these errors were encountered: