Skip to content

Commit

Permalink
Merge pull request #106 from craibo/2023.5.1
Browse files Browse the repository at this point in the history
2023.5.1
  • Loading branch information
craibo authored May 7, 2023
2 parents 389e49b + d2f3e8e commit 6032726
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom_components/ha_strava/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ async def _fetch_summary_stats(self, athlete_id: str) -> dict:

_LOGGER.debug("Publishing Summary Stats event")
summary_stats = self._sensor_summary_stats(await response.json())
summary_stats[CONF_SENSOR_ID] = athlete_id
self.event_factory(
data={
"summary_stats": summary_stats,
Expand Down
1 change: 1 addition & 0 deletions custom_components/ha_strava/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
CONF_ATTR_SPORT_TYPE = "sport_type"
CONF_ATTR_LOCATION = "location"
CONF_ATTR_TITLE = "title"
CONF_ATTR_ACTIVITY_ID = "activity_id"

UNIT_BEATS_PER_MINUTE = "bpm"
UNIT_PACE_MINUTES_PER_KILOMETER = "min/km"
Expand Down
7 changes: 7 additions & 0 deletions custom_components/ha_strava/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
CONF_ACTIVITY_TYPE_SWIM,
CONF_ACTIVITY_TYPE_WALK,
CONF_ACTIVITY_TYPE_WORKOUT,
CONF_ATTR_ACTIVITY_ID,
CONF_ATTR_LOCATION,
CONF_ATTR_SPORT_TYPE,
CONF_ATTR_START_LATLONG,
Expand All @@ -53,6 +54,7 @@
CONF_SENSOR_ELEVATION,
CONF_SENSOR_HEART_RATE_AVG,
CONF_SENSOR_HEART_RATE_MAX,
CONF_SENSOR_ID,
CONF_SENSOR_MOVING_TIME,
CONF_SENSOR_PACE,
CONF_SENSOR_POWER,
Expand Down Expand Up @@ -164,11 +166,13 @@ def __init__(self, activity_type, metric, summary_type):

@property
def device_info(self):
athlete_id = self._data.get(CONF_SENSOR_ID, "")
return {
"identifiers": {(DOMAIN, f"strava_stats")},
"name": f"Strava Summary",
"manufacturer": "Strava",
"model": "Activity Summary",
"configuration_url": f"https://www.strava.com/athletes/{athlete_id}",
}

@property
Expand Down Expand Up @@ -358,11 +362,13 @@ def __init__(self, activity_index, sensor_index):

@property
def device_info(self):
activity_id = self._data.get(CONF_SENSOR_ID, "")
return {
"identifiers": {(DOMAIN, f"strava_activity_{self._activity_index}")},
"name": f"Strava Activity {self._activity_index}",
"manufacturer": "Strava",
"model": "Activity",
"configuration_url": f"https://www.strava.com/activities/{activity_id}",
}

@property
Expand Down Expand Up @@ -686,6 +692,7 @@ def capability_attributes(self): # pylint: disable=too-many-return-statements
attr[CONF_ATTR_SPORT_TYPE] = self._data[CONF_ATTR_SPORT_TYPE]
attr[CONF_ATTR_LOCATION] = self._data[CONF_SENSOR_CITY]
attr[CONF_ATTR_TITLE] = self._data[CONF_SENSOR_TITLE]
attr[CONF_ATTR_ACTIVITY_ID] = self._data[CONF_SENSOR_ID]
if self._data[CONF_ATTR_START_LATLONG]:
attr[CONF_LATITUDE] = float(
self._data[CONF_ATTR_START_LATLONG][0]
Expand Down

0 comments on commit 6032726

Please sign in to comment.