Skip to content

xpenno255/peloton_async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Peloton (Async) Integration for Home Assistant

A modern, fully async Home Assistant integration for Peloton using aiohttp.

Features

  • Fully async - Uses aiohttp instead of blocking requests
  • No executor jobs - True async/await throughout
  • Modern architecture - DataUpdateCoordinator pattern
  • Config flow - Easy setup through UI
  • Reauth support - Handles expired credentials gracefully

Installation

Manual Installation

  1. Copy the peloton_async folder to your custom_components directory:

    custom_components/
    └── peloton_async/
        ├── __init__.py
        ├── api.py
        ├── binary_sensor.py
        ├── config_flow.py
        ├── const.py
        ├── manifest.json
        ├── sensor.py
        └── strings.json
    
  2. Restart Home Assistant

  3. Go to Settings → Devices & Services → Add Integration

  4. Search for "Peloton (Async)" and enter your credentials

HACS Installation (Future)

Once published to HACS, you'll be able to install directly from the HACS store.

Entities Created

Binary Sensor

  • Workout Active - Shows if a workout is currently in progress

Sensors

  • Duration - Workout duration in minutes
  • Current Workout Duration - Time elapsed in current workout (live updates during active workout)
  • Time Remaining - Calculated time remaining in current workout
  • Distance - Distance covered (respects user's unit preference)
  • Calories - Total calories burned
  • Total Output - Total power output in kJ
  • Heart Rate Avg - Average heart rate during workout
  • Heart Rate Max - Maximum heart rate during workout
  • Speed Avg - Average speed (respects user's unit preference)
  • Cadence Avg - Average cadence in RPM

Configuration

All configuration is done through the UI. No YAML required!

Update Interval

The integration polls Peloton's API every 30 seconds. This provides near real-time updates during workouts without overwhelming the API.

Key Improvements Over Original

  1. True Async - No blocking calls wrapped in executors
  2. Better Error Handling - Proper exception handling with retries
  3. Session Management - aiohttp sessions properly managed
  4. Cleaner Code - Simplified sensor creation and updates
  5. Modern Patterns - Follows current Home Assistant best practices

API Client

The api.py module provides a clean async interface to Peloton's API:

api = PelotonAPI(username, password)
await api.login()
workouts = await api.get_recent_workouts(limit=1)
await api.close()

Troubleshooting

Authentication Errors

If you see authentication errors, go to Settings → Devices & Services → Peloton and click "Reconfigure" to enter new credentials.

No Workouts Found

The integration requires at least one workout in your history. Complete a workout and wait up to 30 seconds for the integration to update.

Connection Issues

Check your Home Assistant logs for detailed error messages. The integration will automatically retry on temporary connection failures.

Can Run Alongside Original

Since this uses the domain peloton_async, it can run alongside the original peloton integration without conflicts. This lets you test the async version while keeping your existing setup.

Development

Want to extend this integration? The code is structured for easy modifications:

  • api.py - Add new API endpoints here
  • sensor.py - Add new sensor types here
  • binary_sensor.py - Add new binary sensors here

License

MIT License - Feel free to modify and distribute

Credits

Based on the original pylotoncycle library and Home Assistant Peloton integration, completely rewritten for modern async patterns.

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages