# Strava Integration

WatchMy.bike integrates with Strava to automatically sync your bike distances. This guide explains how to connect Strava, import gear, and troubleshoot common issues.

## What Strava Sync Does

When connected, WatchMy.bike:
- **Syncs bike distances** every 6 hours automatically
- **Imports existing Strava gear** with their accumulated distances
- **Links bikes** so activities on Strava update your WatchMy.bike records
- **Tracks component distances** based on when they were installed

## Connecting Your Strava Account

### Step 1: Navigate to Strava Settings
Go to **Settings > Strava** in your WatchMy.bike account.

### Step 2: Authorize Access
Click "Connect Strava" and you'll be redirected to Strava's authorization page. WatchMy.bike requests read-only access to:
- Your profile information
- Your activities
- Your gear (bikes)

### Step 3: Confirm Authorization
Click "Authorize" on Strava's page. You'll be redirected back to WatchMy.bike with your account now connected.

## Importing Strava Gear

After connecting, you can import bikes from Strava:

1. Go to **Bikes > Strava Bikes** tab
2. You'll see all bikes registered in your Strava account
3. Click "Import" next to any bike you want to add
4. The bike is created in WatchMy.bike with its existing distance

**Note**: Imported bikes retain their Strava distance history. Component distances start from the date you add them.

## Linking Existing Bikes

If you already have bikes in WatchMy.bike that match your Strava gear:

1. Go to your bike's detail page
2. Click "Edit"
3. In the Strava section, select the matching Strava bike
4. Save changes

Now your WatchMy.bike bike will receive automatic distance updates from that Strava gear.

## How Sync Works

### Automatic Sync
- Runs every **6 hours** automatically
- Updates all linked bikes with their current Strava distances
- No manual action required

### Manual Sync
- Go to **Settings > Strava**
- Click "Sync Now" to trigger an immediate update
- Useful after completing a ride and wanting to see updated numbers

## Understanding Distance Calculation

WatchMy.bike uses two distance sources:

1. **Strava Distance**: Automatically synced from your Strava activities
2. **Base Distance**: Manual distance you can add for pre-Strava rides

**Total Distance = Strava Distance + Base Distance**

This means you can account for kilometers ridden before you connected Strava.

## Unlinking from Strava

### Unlink a Single Bike
1. Go to the bike's edit page
2. Clear the Strava bike selection
3. Save changes

The bike keeps its current distance but stops receiving updates.

### Disconnect Strava Entirely
1. Go to **Settings > Strava**
2. Click "Disconnect Strava"
3. All bike links are removed, but your bikes and their distances are preserved

You can also revoke access from within Strava at Settings > My Apps.

## Troubleshooting

### Distances Not Updating
- Check that your Strava account is still connected (Settings > Strava)
- Verify the bike is linked to the correct Strava gear
- Try a manual sync
- Ensure the activity was recorded with the correct gear in Strava

### Wrong Bike Getting Distance
- Check your Strava default bike settings
- Verify you selected the correct gear when uploading the activity
- You can edit activities in Strava to change the associated gear

### Import Not Working
- Ensure you have bikes registered in Strava (Settings > My Gear in Strava)
- Try disconnecting and reconnecting your Strava account
- Check that you authorized all required permissions

### Duplicate Bikes
If you imported a Strava bike and also created it manually:
1. Delete one of the duplicates
2. If you delete the imported one, link the manual bike to that Strava gear
3. Update the base distance if needed to account for the difference

## Privacy Notes

- WatchMy.bike only reads your Strava data; we never post to your Strava account
- Activity details (routes, times, segments) are not stored
- Only distance totals per bike are synced
- You can disconnect at any time without losing your WatchMy.bike data
