From cc75bc53ee681192e6a3e8791af968beceabb3e9 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski <75446+jpawlowski@users.noreply.github.com> Date: Tue, 20 Jan 2026 16:44:18 +0000 Subject: [PATCH] feat(services): add average indicator for hourly resolution in charts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add visual indicators to distinguish hourly aggregated data from original 15-minute interval data in ApexCharts output. Changes: - Chart title: Append localized suffix like "(Ø hourly)" / "(Ø stündlich)" - Y-axis label: Append "(Ø)" suffix, e.g., "øre/kWh (Ø)" The suffix pattern avoids confusion with Scandinavian currency symbols (øre/öre) which look similar to the average symbol (Ø) when used as prefix. Added hourly_suffix translations for all 5 languages (en, de, sv, nb, nl). Impact: Users can now clearly see when a chart displays averaged hourly data rather than original 15-minute prices. --- .../tibber_prices/custom_translations/de.json | 1 + .../tibber_prices/custom_translations/en.json | 1 + .../tibber_prices/custom_translations/nb.json | 3 ++- .../tibber_prices/custom_translations/nl.json | 3 ++- .../tibber_prices/custom_translations/sv.json | 3 ++- .../tibber_prices/services/get_apexcharts_yaml.py | 9 +++++++++ 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/custom_components/tibber_prices/custom_translations/de.json b/custom_components/tibber_prices/custom_translations/de.json index a697d34..455b2be 100644 --- a/custom_components/tibber_prices/custom_translations/de.json +++ b/custom_components/tibber_prices/custom_translations/de.json @@ -2,6 +2,7 @@ "apexcharts": { "title_rating_level": "Preisphasen Tagesverlauf", "title_level": "Preisniveau", + "hourly_suffix": "(Ø stündlich)", "best_price_period_name": "Bestpreis-Zeitraum", "peak_price_period_name": "Spitzenpreis-Zeitraum", "notification": { diff --git a/custom_components/tibber_prices/custom_translations/en.json b/custom_components/tibber_prices/custom_translations/en.json index a100578..f860318 100644 --- a/custom_components/tibber_prices/custom_translations/en.json +++ b/custom_components/tibber_prices/custom_translations/en.json @@ -2,6 +2,7 @@ "apexcharts": { "title_rating_level": "Price Phases Daily Progress", "title_level": "Price Level", + "hourly_suffix": "(Ø hourly)", "best_price_period_name": "Best Price Period", "peak_price_period_name": "Peak Price Period", "notification": { diff --git a/custom_components/tibber_prices/custom_translations/nb.json b/custom_components/tibber_prices/custom_translations/nb.json index 2e5403a..836265e 100644 --- a/custom_components/tibber_prices/custom_translations/nb.json +++ b/custom_components/tibber_prices/custom_translations/nb.json @@ -2,6 +2,7 @@ "apexcharts": { "title_rating_level": "Prisfaser dagsfremdrift", "title_level": "Prisnivå", + "hourly_suffix": "(Ø per time)", "best_price_period_name": "Beste prisperiode", "peak_price_period_name": "Toppprisperiode", "notification": { @@ -505,4 +506,4 @@ "now": "nå" }, "attribution": "Data levert av Tibber" -} \ No newline at end of file +} diff --git a/custom_components/tibber_prices/custom_translations/nl.json b/custom_components/tibber_prices/custom_translations/nl.json index cbaae35..1ee48b7 100644 --- a/custom_components/tibber_prices/custom_translations/nl.json +++ b/custom_components/tibber_prices/custom_translations/nl.json @@ -2,6 +2,7 @@ "apexcharts": { "title_rating_level": "Prijsfasen dagverloop", "title_level": "Prijsniveau", + "hourly_suffix": "(Ø per uur)", "best_price_period_name": "Beste prijsperiode", "peak_price_period_name": "Piekprijsperiode", "notification": { @@ -505,4 +506,4 @@ "now": "nu" }, "attribution": "Gegevens geleverd door Tibber" -} \ No newline at end of file +} diff --git a/custom_components/tibber_prices/custom_translations/sv.json b/custom_components/tibber_prices/custom_translations/sv.json index 6a80a93..5ea3e59 100644 --- a/custom_components/tibber_prices/custom_translations/sv.json +++ b/custom_components/tibber_prices/custom_translations/sv.json @@ -2,6 +2,7 @@ "apexcharts": { "title_rating_level": "Prisfaser dagsprogress", "title_level": "Prisnivå", + "hourly_suffix": "(Ø per timme)", "best_price_period_name": "Bästa prisperiod", "peak_price_period_name": "Toppprisperiod", "notification": { @@ -505,4 +506,4 @@ "now": "nu" }, "attribution": "Data tillhandahålls av Tibber" -} \ No newline at end of file +} diff --git a/custom_components/tibber_prices/services/get_apexcharts_yaml.py b/custom_components/tibber_prices/services/get_apexcharts_yaml.py index 0e18985..d5221b0 100644 --- a/custom_components/tibber_prices/services/get_apexcharts_yaml.py +++ b/custom_components/tibber_prices/services/get_apexcharts_yaml.py @@ -314,6 +314,10 @@ async def handle_apexcharts_yaml(call: ServiceCall) -> dict[str, Any]: # noqa: use_subunit = display_mode == DISPLAY_MODE_SUBUNIT price_unit = get_display_unit_string(config_entry, currency) + # Add average symbol suffix for hourly resolution (suffix to avoid confusion with øre/öre) + if resolution == "hourly": + price_unit = f"{price_unit} (Ø)" + # Get entity registry for mapping entity_registry = async_get_entity_registry(hass) @@ -532,6 +536,11 @@ async def handle_apexcharts_yaml(call: ServiceCall) -> dict[str, Any]: # noqa: day_translated = get_translation(["selector", "day", "options", day], user_language) or day.capitalize() title = f"{title} - {day_translated}" + # Add hourly suffix to title when using hourly resolution + if resolution == "hourly": + hourly_suffix = get_translation(["apexcharts", "hourly_suffix"], user_language) or "(Ø hourly)" + title = f"{title} {hourly_suffix}" + # Configure span based on selected day # For rolling window modes, use config-template-card for dynamic config if day == "yesterday":