Strava sensors

Thank you for sharing your solution.
Unfortunately I’ve got error message when tried to repeat it on my Home Assistant 0.104.3 (in docker). During config check I see following :

Invalid config for [sensor.rest]: [json_attributes_path] is an invalid option for [sensor.rest]. Check: sensor.rest->json_attributes_path.

Do you have any ideas why it could happen? I suppose your config above are working and I just copied it in my strava_sensor.yaml file (within sensors folder when other sensor files are located).

Not sure why is happening. Have you tried single quotes in the json_attributes_path?

I just tried following yaml file for strava sensor but with same error message :frowning:

# Rate Limits 	600 requests every 15 minutes, 30000 daily


  - platform: command_line
    name: Strava Access Token
    command: "python3 /config/python_scripts/strava.py"
    scan_interval: 3600
      
  - platform: rest
    name: Strava Last Activity
    json_attributes_path: '$.[0]'
    json_attributes:
      - distance
      - total_elevation_gain
      - average_speed
      - average_heartrate
      - moving_time
    resource_template: https://www.strava.com/api/v3/athlete/activities?access_token={{ states('sensor.strava_access_token') }}
    method: GET
    value_template: '{{ value_json[0].name }}'
    scan_interval: 3600   

  - platform: template
    sensors:  
      strava_last_distance:
        friendly_name: 'Strava Last Distance'
        value_template: "{{ ((state_attr('sensor.strava_last_activity', 'distance'))/1000) | round(2) }}"
        unit_of_measurement: "km"
        entity_id: sensor.strava_last_activity
      strava_last_elevation:
        friendly_name: 'Strava Last Elevation'
        value_template: "{{ (state_attr('sensor.strava_last_activity', 'total_elevation_gain')) | round(1) }}"
        unit_of_measurement: "m"
        entity_id: sensor.strava_last_activity

It looks like the code is correct. I am thinking that it has to be related to your HA version. In february 2020, there was a change regarding json/xml in rest sensors. I am working with the updated HA 0.111.4, so it must be that: https://github.com/home-assistant/core/pull/31809
Anyone?

You can try to remove both json_attributes_path and json_attributes, but that will force you to do a rest sensor for each value.

Thank you very much for assistance!
I’ll continue my research and may be update to latest version of HA (despite the fact that it might be painful due to breaking changes)

After update to the latest version of HA strava sensor start to work!

@hellad glad to hear that everything is working!

I am correcting my previous post of rhythm #43

Many people in this thread have asked for a dedicated Strava Home Assistant Component; one that avoids rate-limit-, authentication-, and other issues with Strava’s API.

I’ve recently started building a Strava Home Assistant Integration and I’d love to hear your thoughts: https://github.com/codingcyclist/ha_strava

As of now, the integration can only pull data about the ten most recent activities on Strava. Down the line, it’d be great to add picture-, summary stats-, and other cool features, but it’s unclear yet when I’ll find the time to do that.

Please reach out if you have feedback and/or would like to contribute.

1 Like

Thank you very much for writing this - it works great. Just a shame that Strava class everyone in Europe as wanting to use KM’s and not Miles like we do in the UK. Will sort out a template sensor to fix that but it’s nice to get my strava rides back into HA :grinning:

Good job! Hope you can implement the summary stats soon!

@rcont @BertrumUK I’m glad you like custom component so far!

I’m already working on pulling YTD and all-time summary stats for biking, running, and swimming. Also, I’m adding a camera entity to feature recent activity pictures as a photo-carousel…stay tuned

1 Like

Summary Stats and Photo Carousel are now available. Feel free to check it out (Link) and let me know what you think :slight_smile:

Thanks Simon. Would still like a metric/Imperial option for us UK users :grimacing:

@codingcyclist good afternoon, I would like a help because I don’t know what to put in the Website field on the website https://www.strava.com/settings/api because I can generate the client id and client secret, but when will I put it in HA gives the following error when opening the page:

{“message”: “Bad Request”, “errors”: [{“resource”: “Application”, “field”: “redirect_uri”, “code”: “invalid”}]}

Your addon is not showing in intregations from newer HA. How can i install it??

Did you ever get this resolved? I recently installed the integration and have the same error as your post.

Hi @codingcyclist, i can’t install Strava addons update 0.1.1 with hacs, an error no content to download appears.

Something have change ?
I ve try to re-add custom repo but i’ve this issue :


Thanks for your help

I have the same error.

Hi,
Works on 0.1.2 version, thanks @codingcyclist

Hi. I have the same problem. Anyone who got this to work?