Add translation support for multi-value error and warning entities#39
Closed
Add translation support for multi-value error and warning entities#39
Conversation
- Add translation keys for all error codes in strings.json, en.json, and de.json - Modify ErrorSensor and WarningSensor to load and use translations - Add extra_state_attributes with raw error codes for automation use - Change separator from comma to comma+space for better readability Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
Add FAQ section explaining how to use error codes in automations Update entity table to clarify translated error messages and attribute access Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
- Move _translate_error method from ErrorSensor and WarningSensor to BwtEntity - Remove code duplication - Remove trailing whitespace for better code style Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
- Create TranslatableErrorMixin class for shared translation logic - Rename _translate_error to _translate_code to reflect dual purpose - Move async_added_to_hass translation loading to mixin - Update ErrorSensor and WarningSensor to use the mixin - Eliminates all code duplication between error and warning sensors Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
- Add _get_errors() helper method to ErrorSensor - Add _get_warnings() helper method to WarningSensor - Remove extra blank line between classes - Further reduce code duplication Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
Add comprehensive docstring to TranslatableErrorMixin class explaining its purpose and the _translations attribute lifecycle Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate Home Assistant integration for multi-value entities
Add translation support for multi-value error and warning entities
Feb 13, 2026
Owner
|
@copilot Checks are failing, please investigate |
- Remove invalid entity_component._.state.error structure from JSON files - Replace async translation loading with hardcoded dictionaries - Add _ERROR_TRANSLATIONS_EN and _ERROR_TRANSLATIONS_DE constants - Simplify TranslatableErrorMixin to use hardcoded translations - Remove async_added_to_hass overrides from ErrorSensor and WarningSensor - Fix HomeAssistant translation validation failures Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
- Add translations under entity.sensor.errors.state.{code} structure
- Add translations under entity.sensor.warnings.state.{code} structure
- Load translations using async_get_translations from HA
- Use translation category "entity" instead of "entity_component"
- Restore async_added_to_hass to load translations on entity initialization
- Support both English and German through HA translation files
Co-authored-by: dkarv <3708591+dkarv@users.noreply.github.com>
Contributor
Author
Fixed the hassfest validation errors. The issue was using an invalid translation structure. Now using the proper HomeAssistant format: Changes in commit 4c0752e:
The integration now properly uses HA's translation system instead of hardcoded values. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Error and warning entities display comma-separated error codes (e.g.,
OFFLINE_MOTOR_1,REGENERATIV_20) which HomeAssistant's standard translation mechanisms cannot handle since they only translate single enum values, not concatenated strings.Implementation
strings.json,en.json,de.jsonunderentity.sensor.{sensor_key}.state.*formatasync_get_translations()when entity is added to HA, provides_translate_code()methoderror_codes/warning_codesattributes for automation useThe implementation uses HomeAssistant's official translation system with the proper format (
entity.sensor.errors.state.{error_code}) that passes hassfest validation.Example
Before: State shows
OFFLINE_MOTOR_1,REGENERATIV_20After:
Motor 1 offline, Regeneration salt level < 20%(or German equivalent)error_codes: ["OFFLINE_MOTOR_1", "REGENERATIV_20"]for automations💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.