Give firmware from before the languages Home Assistant's English words, not the screens' new language

The app fetched Home Assistant's state words in the screens' language only, so a screen still on 0.2.75 showed
"Speelt" among its own English words (and would get letters it can't draw). It now keeps them per language, the
screens' and English, and picks the set of the screen it writes for. Found in the second test pass on the boards.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Max Gramser
2026-09-19 20:02:17 +02:00
parent f7c452e7a7
commit 2b9ba7ec2b
2 changed files with 45 additions and 10 deletions
+16
View File
@@ -240,6 +240,22 @@ class ClockPinTests(unittest.IsolatedAsyncioTestCase):
chosen.region.change({'clock': 'auto'})
self.assertFalse(chosen.region.pinned, 'the owner chose a clock')
async def test_home_assistants_words_follow_the_screen(self):
"""Old firmware keeps English words from Home Assistant too, a new one its language's (found in the second test pass:
a playing media player said "Speelt" among English words on firmware 0.2.75)."""
from server import HomeAssistant
ha = HomeAssistant(None, 'http://127.0.0.1:1/api', 'token')
ha.language_of = lambda: 'nl'
ha.words_by_language = {'nl': {'state': 'Speelt'}, 'en': {'state': 'Playing'}}
self.assertEqual(ha.state_words, {'state': 'Speelt'})
for context, word in ((i18n.LEGACY, 'Playing'), ({'language': 'nl', 'legacy': False}, 'Speelt'),
({'language': 'de', 'legacy': False}, 'Speelt')):
token = i18n.SCREEN.set(context)
try:
self.assertEqual(ha.state_words, {'state': word})
finally:
i18n.SCREEN.reset(token)
async def test_language_and_region_over_http(self):
from server import create_app
from aiohttp.test_utils import TestClient, TestServer