Commit 58a37a6
feat: translatable sensor names (169 entities)
Sensor names were hardcoded English regardless of the user's Home
Assistant language. The integration already ships 22 languages, but they
only covered the config and options flows -- there was no entity section
at all.
Names now come from entity.sensor.<key>.name via _attr_translation_key.
The English text was generated from sensor_def['name'], so what users see
is unchanged; other languages can now be contributed without touching
Python.
The strings were generated in CI rather than locally. sensor.py imports
homeassistant.components.sensor and cannot be imported on the Windows dev
machine, so doing this locally would have meant parsing source -- and
many definitions are built by _pv_string_sensors() and _phase_sensors()
with f-strings, which is where that would have gone wrong. The throwaway
workflow imported the module properly on Linux and uploaded the real 169
definitions; it is removed again in this commit.
The failure mode for a missing key is quiet: Home Assistant does not fall
back to anything readable, so the entity simply has no label while
continuing to work. tests_ha asserts every key has text, that no orphaned
entries remain, and that the English matches SENSOR_DEFINITIONS exactly
-- the last of which is what proves this changed nothing visible.
number/select/time names stay in Python for now; those platforms were
only just moved onto GrowattEntity and their naming should settle first.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 2a17d06 commit 58a37a6
5 files changed
Lines changed: 1096 additions & 61 deletions
File tree
- .github/workflows
- custom_components/growatt_modbus
- translations
- tests_ha
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1388 | 1388 | | |
1389 | 1389 | | |
1390 | 1390 | | |
1391 | | - | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1392 | 1398 | | |
1393 | 1399 | | |
1394 | 1400 | | |
| |||
0 commit comments