Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MMM-OneCallWeather.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
& .day,
& .max-temp,
& .min-temp,
& .wind-speed {
& .wind-speed,
& .alert {
text-align: center;
}

Expand Down
27 changes: 26 additions & 1 deletion MMM-OneCallWeather.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Module.register("MMM-OneCallWeather", {
roundTemp: true,
showCurrent: true,
showForecast: true,
showAlerts: false,
forecastLayout: "columns", // "columns" (days as columns) or "rows" (days as rows)
arrangement: "vertical", // "vertical" (forecast below current) or "horizontal" (forecast next to current)

Expand Down Expand Up @@ -137,8 +138,14 @@ Module.register("MMM-OneCallWeather", {
weatherType: this.convertWeatherType(data.current.weather[0].icon),
humidity: data.current.humidity,
feelsLikeTemp: data.current.feels_like.toFixed(1),
precipitation: current.rain + current.snow
precipitation: current.rain + current.snow,
alerts: []
Comment thread
KristjanESPERANTO marked this conversation as resolved.
};

if (Object.hasOwn(data, "alerts")) {
currently.alerts = data.alerts;
}

current.push(currently);
Log.debug(`current weather is ${JSON.stringify(currently)}`);
}
Expand Down Expand Up @@ -644,6 +651,24 @@ Module.register("MMM-OneCallWeather", {
currentRow3.appendChild(currentCell3);
table.appendChild(currentRow3);

// Row 4: Current weather alerts
if (this.config.showAlerts && currentWeather.alerts.length > 0) {
const currentRow4 = document.createElement("tr");
const currentCell4 = document.createElement("td");
currentCell4.colSpan = colspan;
currentCell4.className = "alert";
let alertText = "";
for (const weatherAlert of currentWeather.alerts) {
if (alertText !== "") {
alertText += "<br />";
}
alertText += weatherAlert.event;
}
currentCell4.innerHTML = alertText;
currentRow4.appendChild(currentCell4);
table.appendChild(currentRow4);
}

return table;
},

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ The following properties can be configured:
| `windUnits` | The units to use for wind speed.<br><br>**Possible values:** `"mph"` (miles per hour), `"kmph"` (kilometers per hour), `"ms"` (meters per second)<br>**Default value:** `"mph"`<br>This value is optional. By default the weatherforecast module will display wind speed in miles per hour. |
| `roundTemp` | Round temperature values to nearest integer.<br><br>**Possible values:** `true` (round to integer) or `false` (display exact value with decimal point)<br>**Default value:** `false` |
| `showCurrent` | Show the current weather section.<br><br>**Possible values:** `true` or `false`<br>**Default value:** `true` |
| `showAlerts` | Show the current weather alerts.<br><br>**Possible values:** `true` or `false`<br>**Default value:** `false` |
| `showForecast` | Show the forecast section.<br><br>**Possible values:** `true` or `false`<br>**Default value:** `true` |
| `forecastLayout` | Defines how the forecast is structured internally.<br><br>**Possible values:** `"columns"` (days displayed as table columns), `"rows"` (days displayed as table rows)<br>**Default value:** `"columns"` |
| `arrangement` | How current weather and forecast are positioned relative to each other (only relevant when both `showCurrent` and `showForecast` are `true`).<br><br>**Possible values:** `"vertical"` (forecast below current weather), `"horizontal"` (forecast next to current weather)<br>**Default value:** `"vertical"` |
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.