From 5b01bba80761ff709dd536f6fb4aa493386108be Mon Sep 17 00:00:00 2001 From: Ross Younger Date: Wed, 29 Nov 2023 22:46:20 +1300 Subject: [PATCH] weather: showHumidity is now a string specifying the position Supported positions: "wind" "temp" "feelslike" "below" "false" (where "false" means not displayed). We recognise true and false (boolean, unquoted) as legacy values and emit a deprecation warning. This also gives humidity its own css class, to allow for custom styling. --- CHANGELOG.md | 1 + modules/default/weather/current.njk | 18 ++++++++++++++++-- modules/default/weather/weather.js | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 468cc9ba48..55a5428819 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ _This release is scheduled to be released on 2024-04-01._ ### Added - Output of system information to the console for troubleshooting (#3328 and #3337), ignore errors under aarch64 +- weather: `showHumidity` config is now a string. Supported values: "wind", "temp", "feelslike", "below", "false". ### Updated diff --git a/modules/default/weather/current.njk b/modules/default/weather/current.njk index e2fa2f51fb..2fdeeec4c7 100644 --- a/modules/default/weather/current.njk +++ b/modules/default/weather/current.njk @@ -1,3 +1,8 @@ +{% macro humidity() %} + {% if current.humidity %} + {{ current.humidity | decimalSymbol }}  + {% endif %} +{% endmacro %} {% if current %} {% if not config.onlyTemp %}
@@ -16,8 +21,8 @@ {% endif %} - {% if config.showHumidity and current.humidity %} - {{ current.humidity | decimalSymbol }}  + {% if config.showHumidity === "wind" or config.showHumidity === true %} + {{ humidity() }} {% endif %} {% if config.showSun %} @@ -40,6 +45,9 @@
{{ current.temperature | roundValue | unit("temperature") | decimalSymbol }} + {% if config.showHumidity === "temp" %} + {{ humidity() }} + {% endif %}
{% if config.showIndoorTemperature and indoor.temperature %} @@ -59,6 +67,9 @@
{% if config.showFeelsLike %} + {% if config.showHumidity === "feelslike" %} + {{ humidity() }} + {% endif %} {{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
@@ -76,6 +87,9 @@ {% endif %}
{% endif %} + {% if config.showHumidity === "below" %} + {{ humidity() }} + {% endif %} {% else %}
{{ "LOADING" | translate }}
{% endif %} diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index 15e6cfc51b..47b0814a4f 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -20,7 +20,7 @@ Module.register("weather", { updateInterval: 10 * 60 * 1000, // every 10 minutes animationSpeed: 1000, showFeelsLike: true, - showHumidity: false, + showHumidity: "false", // this is now a string; see current.njk showIndoorHumidity: false, showIndoorTemperature: false, allowOverrideNotification: false, @@ -86,6 +86,9 @@ Module.register("weather", { Log.warn("Your are using the deprecated config values 'useBeaufort'. Please switch to windUnits!"); this.windUnits = "beaufort"; } + if (this.config.showHumidity === true || this.config.showHumidity === false) { + Log.warn("[weather] Deprecation warning: Please consider updating showHumidity to the new style (config string). Defaulting to 'wind'"); + } // Initialize the weather provider. this.weatherProvider = WeatherProvider.initialize(this.config.weatherProvider, this);