Need help with Multiscrape to get values from a WELSERVER in the house

Need some help – something is just not clicking for me. I have WELSERVER in the house monitoring the Heat/AC temperatures. It will make a XML file that is updated with the values every minute or so. I am trying to use multiscrape to get the values into HA, but I can’t wrap my head around the select setting.
I get a “Could not find a tag for given selector” error with this configuration:
I just don’t understand the select portion of the configuration. All the examples that I find don’t explain how they know what to put where; I feel that there is something simple that escapes me.

This is from my configuration.yaml:

- name: WEL scraper
    resource: http://10.10.0.44:5150/data.xml
    scan_interval: 300
    sensor:
      - unique_id: 1st_supply_temp
        name: Supply Temp for 1st floor
        select: "#folder0 > div.opened > div:nth-child(8) > span > span:nth-child(2) > span.html-attribute-value"
``````````````````````````````````````````````````````````````````````````````````

This is the page from that url: 

````````````````````````````````````````````````````````````````````````````````

<devices>

<device>

<name>date</name>

<value>02/22/2023</value>

</device>

<device>

<name>time</name>

<value>15:53:57</value>

</device>

<device>

<name>Basemnt_Temp</name>

<value>73.174995</value>

</device>

<device>

<name>1st_Supply_Air</name>

<value>74.074989</value>

</device>

<device>

<name>1st_Return_Air</name>

<value>73.849998</value>

</device>

<device>

<name>Attic_Temp</name>

<value>80.150001</value>

</device>

<device>

<name>2nd_Supply_Air</name>

<value>54.049999</value>

</device>

<device>

<name>2nd_Return_Air</name>

<value>70.924995</value>

</device>

<device>

<name>deltaT1</name>

<value>-0.218506</value>

</device>

<device>

<name>deltaT2</name>

<value>16.861397</value>

</device>

</devices>

Welcome :slight_smile: .

Scrape is not the right answer if you have XML available. I suspect you were trying to work out a select statement based off your browser’s HTML rendering of the XML file, which is doomed to failure.

Use a REST sensor instead.

Here’s your XML nicely formatted:

<?xml version="1.0"?>
<devices>
  <device>
    <name>date</name>
    <value>02/22/2023</value>
  </device>
  <device>
    <name>time</name>
    <value>15:53:57</value>
  </device>
  <device>
    <name>Basemnt_Temp</name>
    <value>73.174995</value>
  </device>
  <device>
    <name>1st_Supply_Air</name>
    <value>74.074989</value>
  </device>
  <device>
    <name>1st_Return_Air</name>
    <value>73.849998</value>
  </device>
  <device>
    <name>Attic_Temp</name>
    <value>80.150001</value>
  </device>
  <device>
    <name>2nd_Supply_Air</name>
    <value>54.049999</value>
  </device>
  <device>
    <name>2nd_Return_Air</name>
    <value>70.924995</value>
  </device>
  <device>
    <name>deltaT1</name>
    <value>-0.218506</value>
  </device>
  <device>
    <name>deltaT2</name>
    <value>16.861397</value>
  </device>
</devices>

…and here’s how to pull out Attic_Temp and Basemnt_Temp — the others should be obvious (but do ask if not):

rest:
  - resource: http://10.10.0.44:5150/data.xml
    scan_interval: 300
    sensor:
      - name: Attic temperature
        unit_of_measurement: '°F'
        device_class: temperature
        value_template: >
          {{ value_json['devices']['device']
             |selectattr('name','eq','Attic_Temp')
             |map(attribute='value')
             |first }}
      - name: Basement temperature
        unit_of_measurement: '°F'
        device_class: temperature
        value_template: >
          {{ value_json['devices']['device']
             |selectattr('name','eq','Basemnt_Temp')
             |map(attribute='value')
             |first }}

Awesome! That did exactly what I was looking for!!

My last programming for Clarion for DOS. Where do you learn the magic of these commands used inside the configuration file?

Most of the work is understanding the data structures (dictionaries, lists, strings etc) and how to manipulate them. There’s a very good template editor within HA, under Developer Tools / Template — and that links to a couple of useful references on the Jinja2 template language.

The docs are very good too, although they can take a bit of navigating and it helps if you know what you’re looking for.

In this case, your resource was providing an XML document. I knew that the REST sensor can read XML, converting it to JSON (ref). Your XML was being turned into this:

{
  "devices": {
    "device": [
      {
        "name": "date",
        "value": "02/22/2023"
      },
      {
        "name": "time",
        "value": "15:53:57"
      },
      {
        "name": "Basemnt_Temp",
        "value": "73.174995"
      },
      {
        "name": "1st_Supply_Air",
        "value": "74.074989"
      },
      {
        "name": "1st_Return_Air",
        "value": "73.849998"
      },
      {
        "name": "Attic_Temp",
        "value": "80.150001"
      },
      {
        "name": "2nd_Supply_Air",
        "value": "54.049999"
      },
      {
        "name": "2nd_Return_Air",
        "value": "70.924995"
      },
      {
        "name": "deltaT1",
        "value": "-0.218506"
      },
      {
        "name": "deltaT2",
        "value": "16.861397"
      }
    ]
  }
}

You can paste that into the template editor and play with it:

Thank you. That’s helpful.

1 Like