Summary
Health_Stats currently reflects loss/latency/jitter/DNS only. When speedtest is enabled, users want line speed to contribute to the overall quality score. This change adds an explicit opt-in switch and expected speed values in .env, and updates presentation.py to include a speed penalty term when data is available.
Motivation
- Users care about bandwidth degradation even when latency/jitter are acceptable.
- Speedtest is already collected and exported as
Speed_Stats, but not reflected in the health score.
- Opt-in avoids surprising behavior for users on metered connections.
Proposed Behavior
- Add
SPEEDTEST_SCORE_ENABLED (default false) to gate the feature.
- Add expected line speed values (Mbps) and a
weight_speed config term.
- When enabled and speedtest data exists, compute a normalized speed penalty and apply it to
Health_Stats.
- If speedtest data is missing or speedtest is disabled, skip the speed term (no penalty).
Configuration Changes (.env)
Add under the existing Speedtest section:
SPEEDTEST_SCORE_ENABLED="False" # Explicit opt-in for including speed in Health_Stats
EXPECTED_DOWN_MBPS="500"
EXPECTED_UP_MBPS="500"
weight_speed="0.10" # Adjust other weights to keep total at 1.0
Notes:
- Existing weights currently sum to 1.0. When
weight_speed > 0, users should re-balance the other weights.
Code Changes (High-level)
-
config/__init__.py
- Add to
Config_Presentation:
speedtest_score_enabled = os.getenv("SPEEDTEST_SCORE_ENABLED", "False").lower() in ('true','1','t')
expected_down_mbps = float(os.getenv("EXPECTED_DOWN_MBPS", "0"))
expected_up_mbps = float(os.getenv("EXPECTED_UP_MBPS", "0"))
weight_speed = float(os.getenv("weight_speed", "0"))
-
presentation.py
- When speedtest data exists and
speedtest_score_enabled is true:
- Convert speedtest bits/sec to Mbps.
- Calculate ratio vs expected speeds:
down_ratio = down_mbps / expected_down_mbps
up_ratio = up_mbps / expected_up_mbps
speed_ratio = min(down_ratio, up_ratio, 1.0)
- Convert to penalty:
eval_speed = 1.0 - speed_ratio (0 is good, 1 is worst)
- Update score:
score = 1
- weight_loss * eval_loss
- weight_jitter * eval_jitter
- weight_latency * eval_latency
- weight_dns_latency * eval_dns_latency
- weight_speed * eval_speed
- If expected speeds are missing or zero, skip the speed term and log a warning.
-
README.md (optional but recommended)
- Document new
.env fields and explain how to rebalance weights.
Edge Cases
- Speedtest disabled but score enabled: skip speed term and log.
- Speedtest enabled but no recent data: skip speed term and log.
- Misconfigured expected speeds (0/empty): skip speed term and log.
Backward Compatibility
- Default
SPEEDTEST_SCORE_ENABLED="False" and weight_speed="0" keeps current behavior unchanged.
Acceptance Criteria
- When enabled, low bandwidth reduces
Health_Stats according to the configured weights.
- When disabled, no changes to
Health_Stats vs current behavior.
- Clear
.env documentation for expected speeds and weights.
Summary
Health_Statscurrently reflects loss/latency/jitter/DNS only. When speedtest is enabled, users want line speed to contribute to the overall quality score. This change adds an explicit opt-in switch and expected speed values in.env, and updatespresentation.pyto include a speed penalty term when data is available.Motivation
Speed_Stats, but not reflected in the health score.Proposed Behavior
SPEEDTEST_SCORE_ENABLED(default false) to gate the feature.weight_speedconfig term.Health_Stats.Configuration Changes (.env)
Add under the existing Speedtest section:
Notes:
weight_speed > 0, users should re-balance the other weights.Code Changes (High-level)
config/__init__.pyConfig_Presentation:speedtest_score_enabled = os.getenv("SPEEDTEST_SCORE_ENABLED", "False").lower() in ('true','1','t')expected_down_mbps = float(os.getenv("EXPECTED_DOWN_MBPS", "0"))expected_up_mbps = float(os.getenv("EXPECTED_UP_MBPS", "0"))weight_speed = float(os.getenv("weight_speed", "0"))presentation.pyspeedtest_score_enabledis true:down_ratio = down_mbps / expected_down_mbpsup_ratio = up_mbps / expected_up_mbpsspeed_ratio = min(down_ratio, up_ratio, 1.0)eval_speed = 1.0 - speed_ratio(0 is good, 1 is worst)README.md(optional but recommended).envfields and explain how to rebalance weights.Edge Cases
Backward Compatibility
SPEEDTEST_SCORE_ENABLED="False"andweight_speed="0"keeps current behavior unchanged.Acceptance Criteria
Health_Statsaccording to the configured weights.Health_Statsvs current behavior..envdocumentation for expected speeds and weights.