Skip to content

Parsing XML with Rest Sensor broken #92836

@mutasim

Description

@mutasim

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

rest:
authentication: basic
  username: "root"
  password: "root"
  scan_interval: 30
  resource: http://10.0.11.22/getregister.cgi?124@heat
  sensor:
    - name: "Open Plan Heat - V Value"
      unique_id: open_plan_heat_v_value
      value_template: '{{value_json.cmd.device.reg["@v"]}}'

Anything in the logs that might be useful for us?

Template variable warning: 'dict object' has no attribute '@v' when rendering '{{value_json.cmd.device.reg["@v"]}}'

Additional information

XML file attached: getregister.xml.zip

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions