Skip to content

Translate inverter and battery status states - #1037

Open
it-rec wants to merge 3 commits into
WillCodeForCats:mainfrom
it-rec:feat/status-state-translations
Open

it-rec wants to merge 3 commits into
WillCodeForCats:mainfrom
it-rec:feat/status-state-translations

Conversation

@it-rec

@it-rec it-rec commented Aug 16, 2026 •

Copy link
Copy Markdown

Proposed change

Both status sensors are already SensorDeviceClass.ENUM with options, and the integration ships translations for the config flow, options and repair issues. The entity states however are not translated, so the UI shows the raw option, for example B_STATUS_PRESERVE_CHARGE or I_STATUS_MPPT.

The readable text already exists in the integration - DEVICE_STATUS_TEXT and BATTERY_STATUS_TEXT are exposed as a status_text attribute - but attributes are not shown on the device page, so what a user actually reads is the raw constant.

This adds a translation_key to both status sensors and the corresponding entity.sensor.*.state sections, covering all 8 inverter and all 9 battery states.

Updated for review: all seven shipped languages are now filled in together - en, de, fr, it, nb, nl, pl. The first version only had en and de; that was wrong for this project and is fixed.

English reuses the existing wording from the two *_TEXT tables so there is only one set of terms in the project. I can verify en, de and fr myself; it, nb, nl and pl are my best effort from the English terms, so corrections from native speakers are welcome for those four.

This is not a breaking change. The state value is untouched, only the displayed text changes, so automations and templates comparing against B_STATUS_* or I_STATUS_* keep working.

Testing

Tested on a running Home Assistant instance with an inverter and a battery.

Registry after the change:

sensor.<inverter>_status      translation_key=inverter_status
sensor.<inverter>_b1_status   translation_key=battery_status

Translations served by the frontend API:

[de] B_STATUS_PRESERVE_CHARGE -> Ladung halten     [en] -> Preserve Charge
[de] I_STATUS_MPPT            -> Erzeugung         [en] -> Production

Two things I checked explicitly because they were the risk:

  • State values unchanged. The sensors still report B_STATUS_DISCHARGE and I_STATUS_MPPT through the API after the change.
  • Entity names unchanged. Setting a translation key can take over the entity name; it does not here, because both classes define name as a property.

Rebased on the current main.

Checklist

  • Based on the latest upstream main.
  • One subject only.
  • Tested on a running instance.

Summary by CodeRabbit

  • Improvements
    • Inverter and battery status values now display localized labels in English, German, French, Italian, Norwegian, Dutch, and Polish. Labels cover operating states such as production, charging, and discharging, as well as standby and fault states.

@WillCodeForCats

Copy link
Copy Markdown
Owner

All translations must be updated together.

The status sensors are already SensorDeviceClass.ENUM with options, and
the integration ships translations for config flow and issues, but the
entity states themselves were never translated: the UI shows the raw
option, e.g. B_STATUS_PRESERVE_CHARGE. The plain text existed only as a
status_text attribute, which is not visible on the device page.

Give both status sensors a translation key and add the entity state
strings for en and de. English reuses the wording already in
DEVICE_STATUS_TEXT and BATTERY_STATUS_TEXT so there is only one set of
terms. The state value itself is unchanged, so automations comparing
against B_STATUS_* keep working; only the displayed text changes.

Other languages are left out on purpose rather than machine translated;
they fall back to English.
@it-rec
it-rec force-pushed the feat/status-state-translations branch from b0960db to 567b0b9 Compare August 17, 2026 05:11
Fills in fr, it, nb, nl and pl so all shipped translation files carry the
status states, as requested in review: translations are updated together
rather than one language at a time.

English reuses the wording already in DEVICE_STATUS_TEXT and
BATTERY_STATUS_TEXT. I can verify en, de and fr myself; it, nb, nl and pl
are my best effort from the English terms, so corrections from native
speakers are welcome for those four.
@it-rec
it-rec force-pushed the feat/status-state-translations branch from 567b0b9 to 2279ba6 Compare August 17, 2026 06:01
@it-rec

it-rec commented Aug 17, 2026

Copy link
Copy Markdown
Author

All translations must be updated together.

Done

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 595504b1-b4c4-484e-b2c7-060438710b2e
📥 Commits

Reviewing files that changed from the base of the PR and between 413c9ec and 4c68d70.

📒 Files selected for processing: 8
  • custom_components/solaredge_modbus_multi/sensor.py
  • custom_components/solaredge_modbus_multi/translations/de.json
  • custom_components/solaredge_modbus_multi/translations/en.json
  • custom_components/solaredge_modbus_multi/translations/fr.json
  • custom_components/solaredge_modbus_multi/translations/it.json
  • custom_components/solaredge_modbus_multi/translations/nb.json
  • custom_components/solaredge_modbus_multi/translations/nl.json
  • custom_components/solaredge_modbus_multi/translations/pl.json

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Walkthrough

The inverter and battery status sensors now declare translation keys. English, German, French, Italian, Norwegian, Dutch, and Polish translation files provide localized labels for their status values.

Changes: Status sensor translations

Layer / File(s) Summary
Connect status sensors to localized labels
custom_components/solaredge_modbus_multi/sensor.py, custom_components/solaredge_modbus_multi/translations/*.json
The inverter and battery status sensors now declare translation keys. Seven translation files add localized labels for their status values.

Priority: ⬇️ Low

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

Change: Feature

Suggested reviewers: willcodeforcats

Merge Risk: ⚪ Minimal · up to 4c68d

The change localizes inverter and battery status labels across all seven locales without changing native states. Key coverage is complete, and no issue prevents merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Description check Passed The description clearly explains the translation change, scope, compatibility impact, testing performed, and checklist status. It is complete and aligned with the repository guidance.
Title check Passed The title clearly and concisely describes the main change: translating inverter and battery status states.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (7 skipped: 7 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (7 skipped: 7 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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.

2 participants