Struggling with Waze Integration & Access to Attributes

I’m struggling with getting the distance from the Waze integration. By using the Template tool under Developer tools, I can get access to the data that I want using

{{ state_attr("sensor.mark_to_work","duration") }}
{{ state_attr("sensor.mark_to_work","distance") }}
{{ state_attr("sensor.mark_to_work","route") }}

If however I put this into my sensors.yaml, it will only pull the Route and not the duration or distance.

- platform: template
  sensors:
    marktowork_dist:
      value_template: '{{ state.attr("sensor.mark_to_work","distance") }}'
      friendly_name: 'Mark to Work Distance'
    marktowork_time:
      value_template: '{{ state.attr("sensor.mark_to_work","duration") }}'
      friendly_name: 'Mark to Work Time'
    marktowork_route:
      value_template: '{{ state_attr("sensor.mark_to_work","route") }}'
      friendly_name: 'Mark to Work Route'

What am i doing wrong? I’m starting to go round the bend!

After many hours of working through this and reviewing countless posts in this community, I finally noticed my problem which was staring me in the face. Mixing up a “.” with a “_” . You know the old saying, you can’t see the wood for the trees? Well there was a huge forest in front of me for 24 hours!

From

    waze_mark_to_work:
      value_template: '{{ state.attr("sensor.mark_to_work","distance") | round(2) }}'
      friendly_name: 'Mark to Work Distance'
      icon_template: mdi:map-marker-distance

to

    waze_mark_to_work:
      value_template: '{{ state_attr("sensor.mark_to_work","distance") | round(2) }}'
      friendly_name: 'Mark to Work Distance'
      icon_template: mdi:map-marker-distance

Hallelujah, glad that one is solved. I’ll go hang my head in shame!