refactor(options_flow): optimize loading of override translations based on active overrides

This commit is contained in:
Julian Pawlowski 2026-04-12 08:54:41 +00:00
parent a8d5230531
commit 9e1ba10f0b

View file

@ -378,7 +378,6 @@ class TibberPricesOptionsFlowHandler(OptionsFlow):
# Load template and connector from common section # Load template and connector from common section
template = await async_get_translation(self.hass, ["common", "override_warning_template"], language) template = await async_get_translation(self.hass, ["common", "override_warning_template"], language)
_LOGGER.debug("Loaded template: %s", template)
if template: if template:
translations["override_warning_template"] = template translations["override_warning_template"] = template
@ -645,8 +644,8 @@ class TibberPricesOptionsFlowHandler(OptionsFlow):
placeholders = self._get_entity_warning_placeholders("best_price") placeholders = self._get_entity_warning_placeholders("best_price")
placeholders.update(self._get_override_warning_placeholder("best_price", overrides)) placeholders.update(self._get_override_warning_placeholder("best_price", overrides))
# Load translations for override warnings # Load translations for override warnings only when overrides are active
override_translations = await self._get_override_translations() override_translations = await self._get_override_translations() if overrides else {}
return self.async_show_form( return self.async_show_form(
step_id="best_price", step_id="best_price",
@ -717,8 +716,8 @@ class TibberPricesOptionsFlowHandler(OptionsFlow):
placeholders = self._get_entity_warning_placeholders("peak_price") placeholders = self._get_entity_warning_placeholders("peak_price")
placeholders.update(self._get_override_warning_placeholder("peak_price", overrides)) placeholders.update(self._get_override_warning_placeholder("peak_price", overrides))
# Load translations for override warnings # Load translations for override warnings only when overrides are active
override_translations = await self._get_override_translations() override_translations = await self._get_override_translations() if overrides else {}
return self.async_show_form( return self.async_show_form(
step_id="peak_price", step_id="peak_price",