Scrape Sensor - XML reading

I am new to the community and currently playing with XML file reading…

My read file is (XX:XX - username:password):
http://XXXX:[email protected]:8031/xml/ix.xml

In XML file I get response:
(look picture - XML OUTPUT)

I need to read inp1 and ds2.
inp1 - need to be readed as is, so as full number 3301 or only 33, both options are good.
ds1 - need to be readed as 21.6, so before last number must be dot, because this is temperature °C.

My configuration file is:
(look picture - CONFIGURATION)

I tried so many different ways that now I’m completly stuck.

In HA Log Details (ERROR) I got:
(look picture - ERROR LOG)

How to solve this? How to make dot before last digit on temperature sensor?

Really thank you for your answers…

I have never once used the scrape sensor, but the documentation states it is for HTML rendering, not strict XML. You may not be able to use the scrape sensor at all for what you intend. Assuming that the libraries it is using is not dependent on a root element, you could try:

select: "inp1"
value_template: '{{ Math.floor(value / 100) }}' # Returns first two digits {{ value }} will return raw number

select: "ds2"
value_template: '{{ value / 10 }}'


select: "response inp1"
value_template: '{{ Math.floor(value / 100) }}' # Returns first two digits {{ value }} will return raw number

select: "response ds2"
value_template: '{{ value / 10 }}'

If the libraries it uses needs an “html document,” this will not work no matter what. Also, start with just the select options and remove the value_template part. If you get numbers into home assistant, then start adding the value_template back in and playing with it.

Alternatively, in the past, when I needed XML parsing for sensors, I did something like the following:

- name: temperature
  platform: command_line
  unit_of_measurement: °C
  command: '/usr/bin/curl --insecure "http://hostname/xml/ix.xml" 2>&1 | grep ds2 | awk -F">" ''{print $2}'' | awk -F"<" ''{print $1}'''

This would be dependent on the XML being produced by the service including line breaks for each element, so may or may not work for you.


My configuration is finally working.


Currently I have only problems with value:template.

If I try to use it sensors are not readed at all.
value_template: ‘{{ value / 10 }}’

Maybe it needs to be cast to an numeric data type first?

value_template: '{{ (value | int) / 10 }}'
1 Like

Great. Now it’s working as should… Thank you!


I tried to use the example given but the sensor “Relesae” doesn’t appear in the dashboard ?

Could you help me ?

Really thank you for your answers…

  - platform: yr
  - platform: scrape
    name: Release
    select: ".current-version h1"
    value_template: '{{ value.split(":")[1] }}'


I tried for one week but I can’t make appear the sensor …

Could you help me ?


any help will appreciated :slight_smile:

Hey did you get this working?
I just came across this myself and got it working from the example, it is correct.

      - platform: scrape
        resource: http://USERNAME:PASSWORD@IP:PORT/xml/ix.xml
        select: "ds2"
        value_template: '{{ (value | int) / 10 }}'
        unit_of_measurement: "°C"
        name: Zgoraj-T
1 Like

For me is normaly working… Just be careful, that sensor name is uniqe…