Skip to content

Diagnostic forecast end times#53

Open
TrentHouliston wants to merge 4 commits intomainfrom
cursor/diagnostic-forecast-end-times-fb35
Open

Diagnostic forecast end times#53
TrentHouliston wants to merge 4 commits intomainfrom
cursor/diagnostic-forecast-end-times-fb35

Conversation

@TrentHouliston
Copy link
Contributor

Add two new diagnostic datetime sensors for the end of the final forecast interval and the end of the final 5-minute forecast interval.

Open in Web Open in Cursor 

Co-authored-by: Trent Houliston <trent@houliston.me>
@cursor
Copy link

cursor bot commented Mar 13, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TrentHouliston TrentHouliston requested a review from Copilot March 13, 2026 02:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds diagnostic timestamp sensors to surface the end time of the most recent forecast horizon (overall and specifically 5-minute intervals) for Amber Express, making forecast availability easier to inspect in Home Assistant.

Changes:

  • Adds two new diagnostic timestamp sensors: forecast_end and five_minute_forecast_end.
  • Wires the new sensors into site sensor setup and updates i18n names.
  • Extends the test suite to account for the new entities and validates basic sensor behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
custom_components/amber_express/sensor.py Adds the two new diagnostic timestamp sensor entity classes and registers them for each site.
custom_components/amber_express/translations/en.json Adds display names for the new sensor translation keys.
custom_components/amber_express/tests/test_sensor.py Updates entity-count assertions and adds unit tests for the new sensors.

You can also share your feedback on Copilot code review. Take the survey.

Aggregate forecast-end diagnostic sensors across all channels and add targeted tests for invalid timestamps, cross-channel horizon selection, and select setup edge cases to address review feedback and patch coverage gaps.

Made-with: Cursor
Apply Ruff formatter output to the new channel-sensitive forecast tests so the Ruff format check passes cleanly.

Made-with: Cursor
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two new diagnostic timestamp sensors that expose the end time of the integration’s forecast horizon (overall and 5‑minute-only), primarily to aid debugging/visibility in Home Assistant.

Changes:

  • Add AmberForecastEndSensor and AmberFiveMinuteForecastEndSensor and register them for each site.
  • Add i18n names for the two new sensors.
  • Expand unit tests to cover forecast end behavior (including cross-channel selection) and update entity-count expectations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
custom_components/amber_express/sensor.py Introduces and wires up the two new diagnostic timestamp sensors.
custom_components/amber_express/translations/en.json Adds translation keys for the new sensor entity names.
custom_components/amber_express/tests/test_sensor.py Updates entity-count assertions and adds tests for the new forecast end sensors.
custom_components/amber_express/tests/test_select.py Adds/extends tests for pricing mode select behaviors and async_setup_entry early-return paths.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +767 to +769
end_time = self._parse_datetime(forecast.get(ATTR_END_TIME))
if end_time is None:
continue
Comment on lines +1428 to +1435
coordinator = MagicMock()
coordinator.get_forecasts = MagicMock(
return_value=[
{ATTR_START_TIME: "2024-01-01T10:00:00+00:00", ATTR_END_TIME: None},
{ATTR_START_TIME: "2024-01-01T10:05:00+00:00", ATTR_END_TIME: "not-a-datetime"},
{ATTR_START_TIME: "2024-01-01T10:10:00+00:00", ATTR_END_TIME: "2024-01-01T10:15:00+00:00"},
{ATTR_START_TIME: "2024-01-01T10:15:00+00:00", ATTR_END_TIME: "2024-01-01T10:10:00+00:00"},
]
Comment on lines +74 to +75
"five_minute_forecast_end": { "name": "5 Minute Forecast End" },
"forecast_end": { "name": "Forecast End" },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants