Conversation
Co-authored-by: Trent Houliston <trent@houliston.me>
|
Cursor Agent can help with this pull request. Just |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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_endandfive_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
There was a problem hiding this comment.
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
AmberForecastEndSensorandAmberFiveMinuteForecastEndSensorand 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.
| end_time = self._parse_datetime(forecast.get(ATTR_END_TIME)) | ||
| if end_time is None: | ||
| continue |
| 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"}, | ||
| ] |
| "five_minute_forecast_end": { "name": "5 Minute Forecast End" }, | ||
| "forecast_end": { "name": "Forecast End" }, |
Add two new diagnostic datetime sensors for the end of the final forecast interval and the end of the final 5-minute forecast interval.