removing old endpoints etc

This commit is contained in:
2025-10-06 12:54:15 -07:00
parent 38b4529ecf
commit 76d874fe60
27 changed files with 2737 additions and 439 deletions

View File

@@ -1,6 +1,7 @@
"""Configuration settings for Garmin Analyser."""
import os
import logging
from pathlib import Path
from typing import Dict, Tuple
from dotenv import load_dotenv
@@ -8,6 +9,9 @@ from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Logger for this module
logger = logging.getLogger(__name__)
# Base paths
BASE_DIR = Path(__file__).parent.parent
DATA_DIR = BASE_DIR / "data"
@@ -21,6 +25,46 @@ REPORTS_DIR.mkdir(exist_ok=True)
GARMIN_EMAIL = os.getenv("GARMIN_EMAIL")
GARMIN_PASSWORD = os.getenv("GARMIN_PASSWORD")
# Flag to ensure deprecation warning is logged only once per process
_deprecation_warned = False
def get_garmin_credentials() -> Tuple[str, str]:
"""Get Garmin Connect credentials from environment variables.
Prefers GARMIN_EMAIL and GARMIN_PASSWORD. If GARMIN_EMAIL is not set
but GARMIN_USERNAME is present, uses GARMIN_USERNAME as email with a
one-time deprecation warning.
Returns:
Tuple of (email, password)
Raises:
ValueError: If required credentials are not found
"""
global _deprecation_warned
email = os.getenv("GARMIN_EMAIL")
password = os.getenv("GARMIN_PASSWORD")
if email and password:
return email, password
# Fallback to GARMIN_USERNAME
username = os.getenv("GARMIN_USERNAME")
if username and password:
if not _deprecation_warned:
logger.warning(
"GARMIN_USERNAME is deprecated. Please use GARMIN_EMAIL instead. "
"GARMIN_USERNAME will be removed in a future version."
)
_deprecation_warned = True
return username, password
raise ValueError(
"Garmin credentials not found. Set GARMIN_EMAIL and GARMIN_PASSWORD "
"environment variables."
)
# Bike specifications
class BikeConfig:
"""Bike configuration constants."""
@@ -39,6 +83,28 @@ class BikeConfig:
# Wheel specifications (700x25c)
WHEEL_CIRCUMFERENCE_MM = 2111 # 700x25c wheel circumference
WHEEL_CIRCUMFERENCE_M = WHEEL_CIRCUMFERENCE_MM / 1000
TIRE_CIRCUMFERENCE_M = WHEEL_CIRCUMFERENCE_M # Alias for gear estimation
# Physics-based power estimation constants
BIKE_MASS_KG = 75.0 # Total bike + rider mass in kg
BIKE_CRR = 0.004 # Rolling resistance coefficient
BIKE_CDA = 0.3 # Aerodynamic drag coefficient * frontal area (m²)
AIR_DENSITY = 1.225 # Air density in kg/m³
DRIVE_EFFICIENCY = 0.97 # Drive train efficiency
# Analysis toggles and caps
INDOOR_AERO_DISABLED = True # Disable aerodynamic term for indoor workouts
INDOOR_BASELINE_WATTS = 10.0 # Baseline power for indoor when stationary
POWER_ESTIMATE_SMOOTHING_WINDOW_SAMPLES = 3 # Smoothing window for power estimates
MAX_POWER_WATTS = 1500 # Maximum allowed power estimate to cap spikes
# Legacy constants (kept for compatibility)
AERO_CDA_BASE = 0.324 # Base aerodynamic drag coefficient * frontal area (m²)
ROLLING_RESISTANCE_BASE = 0.0063 # Base rolling resistance coefficient
EFFICIENCY = 0.97 # Drive train efficiency
MECHANICAL_LOSS_COEFF = 5.0 # Mechanical losses in watts
INDOOR_BASE_RESISTANCE = 0.02 # Base grade equivalent for indoor bikes
INDOOR_CADENCE_THRESHOLD = 80 # RPM threshold for increased indoor resistance
# Gear ratios
GEAR_RATIOS = {
@@ -73,7 +139,7 @@ CHART_DPI = 300
CHART_FORMAT = "png"
# Data processing
SMOOTHING_WINDOW = 5 # seconds for gradient smoothing
SMOOTHING_WINDOW = 10 # meters for gradient smoothing
MIN_WORKOUT_DURATION = 300 # seconds (5 minutes)
MAX_POWER_ESTIMATE = 1000 # watts