Skip to content

Expose eBike battery attributes (eBikeBatteryRemaining, eBikeBatteryUsage, eBikeMaxAssistModes) on last_activity sensor #527

Description

@hoffeck

Checklist

  • I have filled out the template to the best of my ability.
  • This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • This issue is not a duplicate feature request of previous feature requests.

Is your feature request related to a problem? Please describe.

I ride an e-bike (Giant Stance E+1) tracked via a paired Edge/watch. Garmin Connect's web UI shows a dedicated "E-Bike-Leistung" (E-Bike Performance) tab per activity with battery level, battery usage, and assist mode — but none of this is exposed on sensor.garmin_connect_last_activity in Home Assistant.

Describe the solution you'd like

Device: Garmin Edge 1050, paired with a Giant Stance E+1 via ANT+ LEV (the standard e-bike profile).
I inspected the raw response from https://connect.garmin.com/gc-api/activity-service/activity/{activityId} (the summary endpoint, via browser devtools) for one of my e-bike activities, and it already contains:

json"eBikeMaxAssistModes": 7,
"eBikeBatteryUsage": 19,
"eBikeBatteryRemaining": 42,
"eBikeAssistModeInfoDTOList": null

Looking at custom_components/garmin_connect/sensor.py, the lastActivity sensor's attributes_fn already passes through all keys from data["lastActivity"] generically (excluding polyline/hasPolyline):

pythonattributes_fn=lambda data: {
k: v
for k, v in (data.get("lastActivity") or {}).items()
if k not in ("polyline", "hasPolyline")
},

So the gap isn't in sensor.py — these fields simply aren't present in the dict returned by ha_garmin's GarminClient.fetch_activity_data() yet. Since that method already extracts a large, specific set of fields from the same summary endpoint (distance, averageHR, avgPower, hrTimeInZone_1..5, etc.), it looks like eBikeBatteryRemaining, eBikeBatteryUsage, and eBikeMaxAssistModes were just not part of the original field list.

Could these three fields be added to whatever builds the lastActivity dict in ha_garmin? Since sensor.py already passes everything through generically, no sensor.py changes should be needed on the integration side once the client returns the fields.

Describe alternatives you've considered

Querying the Garmin API directly outside of the integration (separate auth session, rate-limit risk, duplicate polling).
Manually logging battery % after each ride via an input_number helper — works but defeats the purpose of automatic tracking.

Happy to test a PR/beta build against my account if useful (I have e-bike activities recorded roughly weekly).

Additional context

Integration version: 3.0.10 (installed via HACS)
The "E-Bike-Leistung" (E-Bike Performance) tab on the Garmin Connect activity page confirms the same three metrics visually (Akkuverbrauch/Akkuladestand chart, Assistenzmodus chart) — so this isn't just a stray field, Garmin's own UI relies on it too.
Translation strings in ebike_de.properties (fetched via Garmin Connect's web frontend) confirm the intended labels: battery_level, e_bike_battery_level, e_bike_battery_use — suggesting these are stable, documented-internally field names rather than experimental/unstable ones.
Happy to attach a screenshot of the E-Bike Performance tab if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions