Repository navigation
improve: Skip non-numeric weather forecast values - #672
Conversation
Reviewer's GuideUpdates the weather forecast templates to select only defined numeric values before float/int conversion, preventing provider values such as Flow diagram for numeric weather forecast filteringflowchart LR
A[Weather forecast values] --> B[selectattr defined]
B --> C[selectattr is_number]
C --> D[map float or int]
D --> E[Render forecast]
B --> F[Non-numeric value skipped]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="nspanel_easy_blueprint.yaml" line_range="9932" />
<code_context>
| selectattr("temperature", "defined")
- | rejectattr("temperature", "none")
- | rejectattr("temperature", "eq", "")
+ | selectattr("temperature", "is_number")
| selectattr("datetime", "defined")
| rejectattr("datetime", "none")
</code_context>
<issue_to_address>
**Old forecast values remain visible**
When a panel has displayed a numeric forecast value and the next forecast supplies a non-numeric value for that field while other fields remain numeric, the `is_number` filters exclude the affected field, and the weather-page sequence only writes available values (lines 10348–10359); it does not clear that field’s panel component. Other values update, but the component retains its previous forecast value, so the page shows mixed old and new data.
Clear each affected panel component when its forecast value is filtered out or otherwise unavailable.
Also at `nspanel_easy_blueprint.yaml:9941`, `nspanel_easy_blueprint.yaml:9951`, `nspanel_easy_blueprint.yaml:9961`, `nspanel_easy_blueprint.yaml:9970`, `nspanel_easy_blueprint.yaml:9979`, `nspanel_easy_blueprint.yaml:9989`, `nspanel_easy_blueprint.yaml:9998`, `nspanel_easy_blueprint.yaml:10030`, `nspanel_easy_blueprint.yaml:10034`, `nspanel_easy_blueprint.yaml:10039`, `nspanel_easy_blueprint.yaml:10047`, `nspanel_easy_blueprint.yaml:10053`, `nspanel_easy_blueprint.yaml:10124`, `nspanel_easy_blueprint.yaml:10130`, `nspanel_easy_blueprint.yaml:10145`, `nspanel_easy_blueprint.yaml:10154`, `nspanel_easy_blueprint.yaml:10160`, `nspanel_easy_blueprint.yaml:10169`, `nspanel_easy_blueprint.yaml:10175`, `nspanel_easy_blueprint.yaml:10184`, `nspanel_easy_blueprint.yaml:10193`, `nspanel_easy_blueprint.yaml:10204`, `nspanel_easy_blueprint.yaml:10213`, `nspanel_easy_blueprint.yaml:10224`, `nspanel_easy_blueprint.yaml:10232`, `nspanel_easy_blueprint.yaml:10243`, `nspanel_easy_blueprint.yaml:10252`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: nspanel_easy_blueprint.yaml:9932
Weather forecast values are now filtered with the
is_numbertest before they are converted to numbers, instead of only rejectingnoneand empty strings. A forecast value that is not a number (for exampleunknownfrom a weather provider) is now skipped instead of stopping the automation with a template error, as in #671.rejectattr("x", "none") | rejectattr("x", "eq", "")becomeselectattr("x", "is_number"), for all numeric forecast values:temperature,templow,precipitation,precipitation_probability,wind_speed,humidity,pressure,uv_index,hours_of_sunandthunderstorm_probability. Theselectattr("x", "defined")before them stays, asis_numberfails on undefined values.float/intwithout a default) were reviewed and need no change: they are already guarded byis_number, have defaults, or work on values the Blueprint or Home Assistant formats itself (panel events, timestamps, timer durations, which Home Assistant always formats asH:MM:SS).Checked locally by rendering the 11 changed templates in this version and in #671 with mocked forecasts (600 cases each): with valid data (missing,
none, empty, numbers and numeric strings) the results are identical; with non-numeric values, this version renders while the previous one fails. Expanded size: -1,318 characters; template counts unchanged.Builds on #671 (merge that first); merges cleanly with #669.
Summary by Sourcery
Prevent weather forecast automations from failing when providers return non-numeric forecast values.
Bug Fixes:
Enhancements: