[HELP] Unable to retrieve data from RESTful sensor using json_attributes

I am trying to build my first custom RESTful sensor for integrating data from Surfline onto my dashboard, but I can’t seem to access the data with json_attributes.

In my sensors.yaml file, which is included by my configuration.yaml file as sensor: !include sensors.yaml

- platform: rest
  resource: https://services.surfline.com/kbyg/regions/forecasts/conditions?spotId=5842041f4e65fad6a7708b8d&days=1
  method: GET
  name: surfline
  value_template: '{{ (value_json["data"].conditions[0]) }}'
  json_attributes_path: "$.data.conditions[0]"
  json_attributes:
    - am
    - pm
    - observation
  scan_interval: 900
- platform: template
  sensors:
    surfline_am:
      friendly_name: "AM"
      value_template: "{{ state_attr('sensor.surfline', 'am')['maxHeight']}}"
    surfline_pm:
      friendly_name: "PM"
      value_template: "{{ state_attr('sensor.surfline', 'pm') }}"
    surfline_observation:
      friendly_name: "Observation"
      value_template: "{{ state_attr('sensor.surfline', 'observation') }}"

And here is the JSON response from the API (or you can try it yourself, no authentication is required)

// Unnecessary data omitted for brevity
{
  "associated": {
  },
  "data": {
    "conditions": [
      {
        "observation": "Very small very short period waves from the SW. Light WSW winds with semi clean to slightly sideshore textured conditions.",
        "am": {
          "maxHeight": 2,
          "minHeight": 1,
        },
        "pm": {
          "maxHeight": 1,
          "minHeight": 0.5,
        }
      }
    ]
  }
}

I’ve tried eliminating the json_attributes_path and just making the attribute ‘data’, amongst several other things, and just can’t seem to get it to work. Any help? The state says ‘Unknown’ with my current configuration.

In HA, states cannot be more than 255 characters, while attributes do not have size constraints.
Your value_template: '{{ (value_json["data"].conditions[0]) }}'returns more than that.

Typically, for JSON RESTfull sensors, value_json is set to OK (value_template: "OK") and only attributes are used.