Extracting values from REST sensor (monit xml parsing)

I’ve got some XML from monit with a REST sensor (as shown in: Monit Component - #8 by Gaijin66)

My sensor

- platform: rest
  name: Monit Hassio
  resource: http://ipaddress:2812/_status?format=xml
  authentication: basic
  username: !secret monit_username
  password: !secret monit_password
  json_attributes_path: "$.monit"
  value_template: 'OK'
  json_attributes:
    - "platform"
    - "server"
    - "service"

Then I use this template in the template editor:

{{ state_attr('sensor.monit_hassio', 'service') 
| selectattr("name", "equalto", "felix-control") |list}}

And I end up with this string:

[
  {
    "@type": "5",
    "name": "felix-control",
    "collected_sec": "1667336354",
    "collected_usec": "285429",
    "status": "0",
    "status_hint": "0",
    "monitor": "1",
    "monitormode": "0",
    "onreboot": "0",
    "pendingaction": "0",
    "filedescriptors": {
      "allocated": "5120",
      "unused": "0",
      "maximum": "9223372036854775807"
    },
    "system": {
      "load": {
        "avg01": "1.67",
        "avg05": "1.67",
        "avg15": "1.51"
      },
      "cpu": {
        "user": "10.8",
        "system": "4.9",
        "nice": "0.0",
        "wait": "0.0",
        "hardirq": "0.0",
        "softirq": "2.0",
        "steal": "0.0",
        "guest": "0.0",
        "guestnice": "0.0"
      },
      "memory": {
        "percent": "38.4",
        "kilobyte": "3915212"
      },
      "swap": {
        "percent": "0.0",
        "kilobyte": "0"
      }
    }
  }
]

I would like to extract a float value from that string, like the value for system/load/avg01 into a new sensor and I I can’t seem to figure out how to construct a template to do just that. Any tips?

Ok the solution is to wrap the previous filter template in parentheses, after which you can use selectors on it. In this case: get the first element [0] of the list, then select properties .system.load.avg01

{{ (state_attr('sensor.monit_hassio', 'service') | selectattr("name", "equalto", "felix-control") |list)[0].system.load.avg01}}

Solved!