Skip to content

Commit 8309ea7

Browse files
Merge pull request #5200 from Speshman/feat/4907-expose-load-ml-source
Expose load_ml_source on the ML load stats entity
2 parents 00a7030 + a195669 commit 8309ea7

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/predbat/load_ml_component.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ def _publish_entity(self):
11521152
"model_age_hours": round(model_age_hours, 1) if model_age_hours is not None else None,
11531153
"training_days": self.load_data_age_days,
11541154
"status": self.model_status,
1155+
"load_ml_source": self.ml_source,
11551156
"model_version": MODEL_VERSION,
11561157
"epochs_trained": self.predictor.epochs_trained if self.predictor else 0,
11571158
"friendly_name": "ML Load Stats",

‎apps/predbat/tests/test_load_ml.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@ def get_arg(self, key, default=None, indirect=True, combine=False, attribute=Non
24812481
print(" Testing _publish_entity:")
24822482
mock_base = MockBase()
24832483

2484-
component = LoadMLComponent(mock_base, load_ml_enable=True)
2484+
component = LoadMLComponent(mock_base, load_ml_enable=True, load_ml_source=False)
24852485

24862486
# Mock dashboard_item to capture calls
24872487
def mock_dashboard_item(entity_id, state, attributes, app):
@@ -2572,6 +2572,9 @@ def mock_dashboard_item(entity_id, state, attributes, app):
25722572
assert "status" in attrs2, "status should be in attributes"
25732573
assert attrs2["status"] == "active", f"Expected status 'active', got {attrs2['status']}"
25742574

2575+
# Check load_ml_source
2576+
assert attrs2["load_ml_source"] is False, f"Expected load_ml_source False, got {attrs2['load_ml_source']}"
2577+
25752578
# Check model_version
25762579
assert "model_version" in attrs2, "model_version should be in attributes"
25772580
from load_predictor import MODEL_VERSION

‎docs/load-ml.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,8 @@ ML Component: Validation MAE: 0.3245 kWh
455455

456456
`sensor.predbat_load_ml_stats` publishes three error figures, and they measure different things:
457457

458+
The `load_ml_source` attribute reports whether Load ML is selected as Predbat's load forecast source.
459+
458460
| Attribute | What it measures |
459461
|-----------|------------------|
460462
| `mae_kwh` | Teacher-forced, one step ahead with real data in the lookback. Stays small even when the long-range forecast is useless, so do not read it as overall accuracy. |

0 commit comments

Comments
 (0)