Skip to content

Commit

Permalink
weather: showHumidity is now a string specifying the position
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crazyscot committed Jan 14, 2024
1 parent 58bc14e commit 5b01bba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 16 additions & 2 deletions modules/default/weather/current.njk
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{% macro humidity() %}
{% if current.humidity %}
<span class="humidity"><span>{{ current.humidity | decimalSymbol }}</span><sup>&nbsp;<i class="wi wi-humidity humidity-icon"></i></sup></span>
{% endif %}
{% endmacro %}
{% if current %}
{% if not config.onlyTemp %}
<div class="normal medium">
Expand All @@ -16,8 +21,8 @@
</sup>
{% endif %}
</span>
{% if config.showHumidity and current.humidity %}
<span>{{ current.humidity | decimalSymbol }}</span><sup>&nbsp;<i class="wi wi-humidity humidity-icon"></i></sup>
{% if config.showHumidity === "wind" or config.showHumidity === true %}
{{ humidity() }}
{% endif %}
{% if config.showSun %}
<span class="wi dimmed wi-{{ current.nextSunAction() }}"></span>
Expand All @@ -40,6 +45,9 @@
<div class="large light">
<span class="wi weathericon wi-{{ current.weatherType }}"></span>
<span class="bright">{{ current.temperature | roundValue | unit("temperature") | decimalSymbol }}</span>
{% if config.showHumidity === "temp" %}
<span class="medium bright">{{ humidity() }}</span>
{% endif %}
</div>
<div class="normal light indoor">
{% if config.showIndoorTemperature and indoor.temperature %}
Expand All @@ -59,6 +67,9 @@
<div class="normal medium feelslike">
{% if config.showFeelsLike %}
<span class="dimmed">
{% if config.showHumidity === "feelslike" %}
{{ humidity() }}
{% endif %}
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
</span>
<br />
Expand All @@ -76,6 +87,9 @@
{% endif %}
</div>
{% endif %}
{% if config.showHumidity === "below" %}
<span class="medium dimmed">{{ humidity() }}</span>
{% endif %}
{% else %}
<div class="dimmed light small">{{ "LOADING" | translate }}</div>
{% endif %}
Expand Down
5 changes: 4 additions & 1 deletion modules/default/weather/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5b01bba

Please sign in to comment.