Covert meters to feet (Strava)

Hi i am working on integrating Strava sensors into Homeassistant. But having some problems with conversion, i am hoping the community can help me out.

I am pulling information from the API such as “Comment_count” “kudos_count” “number_of_miles” “last_ride_date”.

I have a couple other sensors i am pulling information from such as “elevation_gain”, “elevation_high” but having issues with these.

strava

The API documentation states these numbers are reported in meters, when i am pulling the information from the API into HAS the unit of measurement is incorrect.

**total_elevation_gain: float **
meters

On the front end in HAS my last ride elevation was “118.4” mt, where as in my app it was “388 ft”
Conversation 118.4 meters to ft = 388.

Am i correct in thinking i need a value template to covert from meters to ft.

value_template: ‘{{ value_json[0].??}’

Any help would much be appreciated.

2 Likes

Not sure how you got the 114.4 meters, but google say your results are more or less correct:

Is this a custom component you’re creating? If so, you can use the HA conversions:

import homeassistant.util.distance as distance_util
from homeassistant.const import (LENGTH_METERS, LENGTH_FEET )

feet = distance_util.convert(meters, LENGTH_METERS, LENGTH_FEET)

Yes a custom component

I made a typo that how i got to the figure…oops :laughing:

Great thanks i will take a look.