Some Strava sensors

I just found this thread. Is is possible to have one entry in sensors.yaml and still get multiple values from Strava?

i do not see why not, you would just need to adjust your value template accordingly

In your example you only use value_template for total_elevation_gain, how could I use it with all the other interesting data, without using a separate - platform: rest entry?

I’ve been looking at the strava documentation but can’t seem to find anything to answer the following question:

Is there a way to pull out my LAST RUN or my LAST RIDE but not my LAST ACTIVITY?

I have a sensor set up to record my last run but sometimes if I go on rides, it shows up there too

Unfortunately, the sensor does not work anymore due to changes how we need to authenticate against the Strava API.

Hi all,

I implemented a new platform for Strava sensors which fixes the token issue and uses the on the PyPi package “stravalib”:
https://github.com/home-assistant/home-assistant/pull/22151

It is currently work in progress. Please feel free to test it. Some feedback is appreciated :slight_smile:
It is based .

1 Like

Hi !

It’s a great work what you did. I will test it when i can.

The sensor still work for me but I tried to make some call with the same parameters with curl and it doesn’t work, weird.

how can I try this as a hassio user? Can I put your files in the custom components folder?

Hi @h4nc,

yes, just copy the homeassistant/components/strava/ folder into your hassio/home-assistant/custom_components/ folder.

Its probably because your OAuth access token expired. The only have a lifetime for some hours. After that we need to refresh the token.

Do you have an manual on how to set up the api service.

What do we have to fill in in website and callback-domain?

@h4nc Please read my posting above.

Do you mean this one:

Couldn’t find how to set up the api correctly.

What do I have to fill in? Sry

I mean this post: Strava sensors

Sorry, it was in a different thread
 I did not notice this

1 Like

Ok, thanks.

I used the user_id (5 digits) for strava_id and the user-secret for the strava_secret. This way I was able to configure it (not with the access token)

The thing is no sensors show up. I restarted ha again after the configuration process.

By the way one more question:

are there more options available? Is there a list of the available options somewhere?

sensor:
  - platform: strava
    stats:
      - recent_run_totals.distance
    activity:
      - distance
      - moving_time

@stv0g I don’t have luck with this component.

As I mentioned before no sensors showed up and there was no error.

One day afterwards I get a persistent notification at a ha restart, which tells me to check my config. Config seems ok, was ok the day before and did not change it.

This is what I get in the log

Error during setup of component strava
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 154, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/strava/__init__.py", line 161, in setup
    hass.data[DOMAIN] = StravaData(hass, config.get(DOMAIN))
  File "/config/custom_components/strava/__init__.py", line 71, in __init__
    self.renew_token()
  File "/config/custom_components/strava/__init__.py", line 130, in renew_token
    if expires_at > datetime.now() + 300:
TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'int'

and

Unable to set up dependencies of strava.sensor. Setup failed for dependencies: strava

Seems that the auth method has changed, and you now need to define a scope. If you are using the old auth method it will not work.

https://developers.strava.com/docs/authentication/

did you manage to get this working again ?

In my opinion as a young developer, i see no way to make the new authentification system work in the config file. You need to develop a little script for this.