Skip to content
Snippets Groups Projects
Commit 8860c40f authored by echicken's avatar echicken :chicken:
Browse files

Weather conditions

parent d46fa924
No related branches found
No related tags found
No related merge requests found
......@@ -16858,8 +16858,12 @@
if (weather.current === void 0)
return false;
var wd = openWeatherMap.wind_direction(weather.current.wind_deg);
var conditions = weather.current.weather.map(function(e) {
return e.main;
}).join(", ");
var ws = "Weather for ".concat(weather.lat.toFixed(2), ", ").concat(weather.lon.toFixed(2));
ws += "\r\n".concat(weather.current.weather[0].main, ", ").concat(weather.current.weather[0].description);
if (conditions.length > 0)
ws += "\r\n".concat(conditions);
ws += "\r\n".concat(weather.current.temp, "\xB0C, feels like ").concat(weather.current.feels_like, "\xB0C");
ws += "\r\nUV: ".concat(weather.current.uvi, " ").concat(uvEmoji(weather.current.uvi));
ws += "\r\nHumidity: ".concat(weather.current.humidity, "%");
......
......@@ -11,11 +11,6 @@ function uvEmoji(uvi: number): string {
return '🟣';
}
function weatherEmoji(icon: string): string {
// just map their icons to some emojis and check for 'd' vs 'n' to choose sun/moon variants
return '';
}
export default class Weather extends Module {
constructor(config: IModuleConfig, devices: Device[]) {
......@@ -33,8 +28,9 @@ export default class Weather extends Module {
const weather = openWeatherMap.call_api_v3({ lat: 43.7554870, lon: -79.4384880, exclude: ['minutely', 'hourly', 'daily', 'alerts'], units: 'metric' });
if (weather.current === undefined) return false;
const wd = openWeatherMap.wind_direction(weather.current.wind_deg);
const conditions = weather.current.weather.map(e => e.main).join(', ');
let ws = `Weather for ${weather.lat.toFixed(2)}, ${weather.lon.toFixed(2)}`;
ws += `\r\n${weather.current.weather[0].main}, ${weather.current.weather[0].description}`;
if (conditions.length > 0) ws += `\r\n${conditions}`;
ws += `\r\n${weather.current.temp}°C, feels like ${weather.current.feels_like}°C`;
ws += `\r\nUV: ${weather.current.uvi} ${uvEmoji(weather.current.uvi)}`;
ws += `\r\nHumidity: ${weather.current.humidity}%`;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment