Skip to content

fix: correct inverted label on manual_refresh_only config option - #2196

Closed
pacso wants to merge 2 commits into
robbrad:masterfrom
pacso:fix/manual-refresh-label-inversion
Closed

fix: correct inverted label on manual_refresh_only config option#2196
pacso wants to merge 2 commits into
robbrad:masterfrom
pacso:fix/manual-refresh-label-inversion

Conversation

@pacso

@pacso pacso commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

The manual_refresh_only config field was labelled "Automatically refresh the sensor" — the exact inverse of what it does. Ticking the box actually disables automatic refresh, and async_step_user defaults the field to True, so new installs silently got no periodic updates while showing a ticked "Automatically refresh" checkbox. This is the likely root cause of the recurring "entities only update on restart" reports.

Fixes #2193

What this does

The field's name, stored value, and semantics are unchanged — no config migration, no inversion in code. This PR only fixes the misleading UI text:

  • Relabelled the checkbox to match its real meaning: "Manual refresh only (disable automatic updates — refresh via the uk_bin_collection.manual_refresh service)" in both the user and reconfigure_confirm steps.
  • Updated strings.json and all translation files. en.json uses the new English label; cy, ga, gd, and pt get proper native translations (the literal service name is preserved).
  • Added a data_description helper explaining: ticked = no automatic refresh; unticked = refresh every update_interval hours.
  • Added a code comment flagging that default=True in async_step_user is questionable given the symptom reports — left unchanged here so it can be decided separately.

What this deliberately does NOT change

  • No changes to __init__.py refresh logic.
  • No changes to stored config entry data / no migration.
  • No change to the default=True value.

Tests

  • New dependency-free (json + pathlib only) regression test tests/test_translations.py that loads strings.json and every translations/*.json, asserts no label is the old inverted string (or an un-negated "automatic" claim), and checks strings.json/en.json stay in sync.
  • Existing test_async_setup_entry_manual_refresh_only_disables_polling (True → update_interval is None, False → timedelta(hours=12)) left in place and still passing.
poetry run pytest custom_components/uk_bin_collection/tests/

Note for reviewers

I'm confident in the Portuguese translation and reasonably confident in the Welsh/Irish/Scottish Gaelic ones, but a native-speaker review on those three would be welcome.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Refined the “Manual refresh only” setting wording in setup and reconfiguration screens.
    • Added clearer help text explaining when data updates occur and that updates can be triggered via the uk_bin_collection.manual_refresh service.
    • Updated the wording consistently across all supported translations.
  • Bug Fixes
    • Replaced confusing “auto refresh” wording with manual-refresh-only behavior descriptions.
  • Tests
    • Added a regression check to ensure every locale’s “manual_refresh_only” label also includes non-empty matching descriptive help text.

The manual_refresh_only checkbox was labelled "Automatically refresh the
sensor" — the exact inverse of the field's stored meaning. Ticking it
actually DISABLES automatic refresh, and async_step_user defaults it to
True, so new installs silently got no periodic updates (issue robbrad#2193).

Relabel the field to match its semantics across strings.json and all
translations (proper native translations for cy/ga/gd/pt), add a
data_description helper, and note the questionable default=True in a
code comment (left unchanged for the maintainer to decide separately).
Field name, stored data, and __init__.py refresh logic are unchanged.

Adds a dependency-free regression test guarding against re-inversion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.04%. Comparing base (9070968) to head (5ea9429).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2196   +/-   ##
=======================================
  Coverage   80.04%   80.04%           
=======================================
  Files          12       12           
  Lines        1393     1393           
=======================================
  Hits         1115     1115           
  Misses        278      278           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ce273ccb-ea5c-4e5e-9bde-7eafbc69674b

📥 Commits

Reviewing files that changed from the base of the PR and between 8e56fcc and 5ea9429.

📒 Files selected for processing (5)
  • custom_components/uk_bin_collection/tests/test_translations.py
  • custom_components/uk_bin_collection/translations/cy.json
  • custom_components/uk_bin_collection/translations/ga.json
  • custom_components/uk_bin_collection/translations/gd.json
  • custom_components/uk_bin_collection/translations/pt.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • custom_components/uk_bin_collection/translations/pt.json
  • custom_components/uk_bin_collection/translations/gd.json
  • custom_components/uk_bin_collection/translations/cy.json
  • custom_components/uk_bin_collection/translations/ga.json

📝 Walkthrough

Walkthrough

The configuration UI now explains manual refresh behavior and references the manual refresh service across English and localized translations. Comments document the unchanged default, while regression tests validate JSON files, label wording, step alignment, and descriptions.

Changes

Manual refresh messaging

Layer / File(s) Summary
Update manual refresh configuration text
custom_components/uk_bin_collection/config_flow.py, custom_components/uk_bin_collection/strings.json, custom_components/uk_bin_collection/translations/*
Setup and reconfiguration labels and descriptions now describe manual-only refresh behavior and the uk_bin_collection.manual_refresh service.
Add translation regression checks
custom_components/uk_bin_collection/tests/test_translations.py
Tests validate translation JSON syntax, prevent inverted labels, ensure English translations match source configuration steps, and require non-empty descriptions for every locale.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • robbrad/UKBinCollectionData#2189: Changes polling behavior based on the manual_refresh_only option, complementing this PR’s configuration text and translation updates.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR only relabels the option and adds descriptions; it does not address the reported automatic refresh failure. Implement the actual refresh bug fix so entities update automatically, or clarify that the issue is only about the misleading label.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: correcting the misleading manual_refresh_only label.
Out of Scope Changes check ✅ Passed The changes stay within the config text, translations, and regression tests needed for the label correction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@custom_components/uk_bin_collection/translations/cy.json`:
- Line 10: Add data_description.manual_refresh_only under both the user and
reconfigure_confirm steps in
custom_components/uk_bin_collection/translations/cy.json (lines 10 and 44),
ga.json (lines 10 and 45), gd.json (lines 10 and 45), and pt.json (lines 10 and
44), using the corresponding source/English descriptions. Update
custom_components/uk_bin_collection/tests/test_translations.py (lines 74-83) to
assert these description keys exist in every locale.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a5bffa0c-024f-41df-9010-9af89b4f7b0f

📥 Commits

Reviewing files that changed from the base of the PR and between 9070968 and 8e56fcc.

📒 Files selected for processing (8)
  • custom_components/uk_bin_collection/config_flow.py
  • custom_components/uk_bin_collection/strings.json
  • custom_components/uk_bin_collection/tests/test_translations.py
  • custom_components/uk_bin_collection/translations/cy.json
  • custom_components/uk_bin_collection/translations/en.json
  • custom_components/uk_bin_collection/translations/ga.json
  • custom_components/uk_bin_collection/translations/gd.json
  • custom_components/uk_bin_collection/translations/pt.json

Comment thread custom_components/uk_bin_collection/translations/cy.json
Add data_description.manual_refresh_only to the user and
reconfigure_confirm steps in cy/ga/gd/pt so no locale falls back to the
English helper text, using native translations (consistent with the
translated labels rather than copying English in).

Extend test_translations.py to assert every locale carries the
data_description key in each step that labels the field.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pacso

pacso commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@robbrad - Whilst this is the simplest fix for the problem, it seems like a counter-intuitive fix. I will submit an alternative PR which inverts the use of the checkbox, such that ticking the box enables the polling interval, and unticking it sets it to manual refresh only.

@pacso

pacso commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@robbrad - I would probably prefer PR #2198 over this fix. Just close this if you agree.

@pacso

pacso commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

The other PR is definitely the right option. Closing this one.

@pacso pacso closed this Jul 30, 2026
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.

entities not refreshing

1 participant