Skip to content

Conversation

@bouwew
Copy link
Contributor

@bouwew bouwew commented Oct 25, 2025

Also, add several missing NL-translations.

Summary by CodeRabbit

  • Localization
    • Added English and Dutch translations, including a new translatable error for attempting to set HVAC mode without a schedule and several new exception messages.
  • Features
    • Added a device reconfiguration flow for updating connection settings.
  • Bug Fixes
    • Error when setting HVAC mode without a schedule now surfaces as a localized, translatable message.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 25, 2025

Walkthrough

Updated the Plugwise climate error to use an i18n translation key/domain when raising HomeAssistantError; replaced the literal ERROR_NO_SCHEDULE message with the key set_schedule_first and added corresponding translation entries (English and Dutch). Dutch file shows a duplicated exceptions block in the diff.

Changes

Cohort / File(s) Summary
Climate logic
custom_components/plugwise/climate.py
Replaced module constant ERROR_NO_SCHEDULE value from the full message to the translation key "set_schedule_first". When enabling HVACMode.AUTO without a schedule, now raises HomeAssistantError(translation_domain=DOMAIN, translation_key=ERROR_NO_SCHEDULE) instead of using a plain string.
UI strings
custom_components/plugwise/strings.json
Added exceptions.set_schedule_first entry with message "Failed setting HVACMode, set a schedule first."
English translations
custom_components/plugwise/translations/en.json
Added exceptions.set_schedule_first translation entry with the message "Failed setting HVACMode, set a schedule first."
Dutch translations & config
custom_components/plugwise/translations/nl.json
Added config.step.reconfigure, new abort messages (not_the_same_smile, reconfigure_successful), and an exceptions block including set_schedule_first. The diff shows the exceptions block inserted twice (duplicate).
Changelog
CHANGELOG.md
Added note about implementing translation for the HomeAssistantError raise message.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HA as HomeAssistant
    participant Climate as plugwise.climate

    User->>HA: set HVAC mode → AUTO
    HA->>Climate: async_set_hvac_mode(AUTO)
    alt schedule exists
        Climate->>Climate: apply schedule/mode
        Climate-->>HA: success
        HA-->>User: confirm
    else no schedule
        Climate-->>HA: raise HomeAssistantError(translation_domain=DOMAIN, translation_key="set_schedule_first")
        HA-->>User: display localized error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to other occurrences of the old literal message in custom_components/plugwise/.
  • Verify correct usage of Home Assistant i18n (translation_domain + translation_key) and that DOMAIN matches translation files.
  • Inspect custom_components/plugwise/translations/nl.json for the duplicate exceptions block and remove the unintended duplicate.

Possibly related PRs

Suggested labels

enhancement, require-dev-pass

Suggested reviewers

  • CoMPaTech
  • github-actions

Poem

🐰 I hopped through code with nimble paws,
I swapped a string for keys and locale laws.
English and Dutch now softly plea,
"Set a schedule first" — in i18n harmony.
🥕

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting a hardcoded error message to a translatable one using HomeAssistant's translation system.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add_HAERROR_translate

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbd51e7 and c1a90a5.

📒 Files selected for processing (1)
  • custom_components/plugwise/translations/nl.json (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-10-08T15:35:25.180Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
Learnt from: bouwew
Repo: plugwise/plugwise-beta PR: 671
File: custom_components/plugwise/switch.py:82-83
Timestamp: 2024-06-22T08:05:56.791Z
Learning: User bouwew prefers to ignore exception handling suggestions for the `pw-beta` branch in the `custom_components/plugwise/switch.py` file.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Setup for HA-core (dev)
  • GitHub Check: Setup for HA-core (release/master)
🔇 Additional comments (3)
custom_components/plugwise/translations/nl.json (3)

21-27: New reconfigure config step looks good.

The new step configuration with host and port fields is properly structured and aligns with the reconfiguration flow mentioned in the PR objectives.


52-54: Abort message translations are well-structured.

The three new abort messages ("anna_with_adam", "not_the_same_smile", "reconfigure_successful") provide clear Dutch translations that align with the intended user messaging.


303-325: The exceptions block is correctly defined with no duplicates.

Verification confirms the JSON file is valid with a single exceptions key containing exactly 7 entries (authentication_failed, data_incomplete_or_missing, error_communicating_with_api, failed_to_connect, invalid_xml_data, set_schedule_first, unsupported_firmware). No duplicate blocks exist.


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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9971ce and 5a7d149.

📒 Files selected for processing (4)
  • custom_components/plugwise/climate.py (2 hunks)
  • custom_components/plugwise/strings.json (1 hunks)
  • custom_components/plugwise/translations/en.json (1 hunks)
  • custom_components/plugwise/translations/nl.json (3 hunks)
🔇 Additional comments (6)
custom_components/plugwise/translations/nl.json (2)

21-27: LGTM - Reconfigure step added.

The reconfigure configuration step is properly structured with description and data fields for host and port.


52-54: LGTM - Abort messages added.

The abort messages follow Home Assistant conventions and provide clear feedback for reconfiguration scenarios.

custom_components/plugwise/translations/en.json (1)

304-306: LGTM - English translation added correctly.

The set_schedule_first exception translation is properly structured and provides a clear error message.

custom_components/plugwise/strings.json (1)

321-323: LGTM - Base exception string defined correctly.

The set_schedule_first exception is properly defined in the base strings file with a clear, actionable message.

custom_components/plugwise/climate.py (2)

57-57: LGTM - Constant updated to translation key.

The ERROR_NO_SCHEDULE constant is correctly updated from a hardcoded message to a translation key, enabling internationalization.


334-337: LGTM - Proper translation-based error handling.

The error is now raised using Home Assistant's translation mechanism with translation_domain and translation_key, which correctly references the translation strings defined in strings.json and translation files.

@bouwew bouwew force-pushed the add_HAERROR_translate branch from 7022fb7 to 8f163f2 Compare November 3, 2025 14:02
@bouwew bouwew force-pushed the add_HAERROR_translate branch from 8f163f2 to cbd51e7 Compare November 5, 2025 14:59
@bouwew bouwew marked this pull request as ready for review November 5, 2025 15:00
@bouwew bouwew requested a review from a team as a code owner November 5, 2025 15:00
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 5, 2025

@bouwew bouwew changed the title Add translation support for the new HAError raise Add translation support for the new HAError raise message Nov 5, 2025
@bouwew bouwew merged commit 287493b into main Nov 5, 2025
13 checks passed
@bouwew bouwew deleted the add_HAERROR_translate branch November 5, 2025 18:24
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.

3 participants