Skip to content

Magic Mirror module to display weather information using the Dark Sky API

Notifications You must be signed in to change notification settings

gerjomarty/MMM-DarkSkyForecast

 
 

Repository files navigation

MMM-DarkSkyForecast

This a module for MagicMirror
https://magicmirror.builders/
https://github.com/MichMich/MagicMirror

Screenshot

A weather module that displays current, hourly and daily forecast information using data from the OpenWeather One Call API. This is a replacement module for MMM-MyWeather, now that Weather Underground no longer allows free API access. This a complete rewrite from scratch but maintains much of the same functionality.

NOTE: This module uses the Nunjucks templating system introduced in version 2.2.0 of MagicMirror. If you're seeing nothing on your display where you expect this module to appear, make sure your MagicMirror version is at least 2.2.0.

Installation

  1. Navigate into your MagicMirror modules folder and execute
    git clone https://github.com/jclarke0000/MMM-DarkSkyForecast.git.
  2. Enter the new MMM-DarkSkyForecast directory and execute npm install.

Configuration

At a minimum you need to supply the following required configuration parameters:

  • apikey
  • latitude
  • longitude

You can request an API key to access data here: https://openweathermap.org/api/one-call-api.

Free tier is fine -- this module will not make any where near 1000 request on one day.

Find out your latitude and longitude here: https://www.latlong.net/.

Other optional parameters

Option Description
updateInterval How frequently, in minutes, to poll for data. Be careful not to set this too frequent so that you don't exceed Dark Sky's 1000 free requests per day cap.

Type Number
Defaults to 10
requestDelay In milliseconds, how long to delay the request. If you have multiple instances of the module running, set one of them to a delay of a second or two to keep the API calls from being too close together.

Type Number
Defaults to 250
updateFadeSpeed How quickly in milliseconds to fade the module out and in upon data refresh. Set this to 0 for no fade.

Type Number
Defaults to 500 (i.e.: 1/2 second).
language The language to be used for display.

Type String
Defaults to the language set for Magic Mirror, but can be overridden with any of the language codes listed here: https://openweathermap.org/api/one-call-api#multi.
colored Whether to present module in colour or black-and-white. Note, if set to false, the monochramtic version of your chosen icon set will be forced.

Type Boolean
Defaults to true
units One of the following: imperial, metric, or [blank].

Type String
Defaults to units set for Magic Mirror.
See https://openweathermap.org/api/one-call-api#data for details on units.
showCurrentConditions Whether to show current temperaure and current conditions icon.

Type Boolean
Defaults to true
showExtraCurrentConditions Whether to show additional current conditions such as high/low temperatures, precipitation and wind speed.

Type Boolean
Defaults to true
showSummary Whether to show the forecast summary.

Type Boolean
Defaults to true
forecastHeaderText Show a header above the forecast display.

Type String
Defaults to ""
showForecastTableColumnHeaderIcons Whether to show icons column headers on the forecast table.

Type Boolean
Defaults to true
showHourlyForecast Whether to show hourly forecast information. when set to true it works with the hourlyForecastInterval and maxHourliesToShow parameters.

Type Boolean
Defaults to true
hourlyForecastInterval How many hours apart each listed hourly forecast is.

Type Number
Defaults to 3
maxHourliesToShow How many hourly forecasts to list.

Type Number
Defaults to 3
showDailyForecast Whether to show daily forecast information. when set to true it works with the maxDailiesToShow parameter.

Type Boolean
Defaults to true
maxDailiesToShow How many daily forecasts to list.

Type Number
Defaults to 3
showPrecipitation Whether to show precipitation information. This affects current conditions, hourly and daily forecasts

Type Boolean
Defaults to true
showWind Whether to show wind information. This affects current conditions, hourly and daily forecasts

Type Boolean
Defaults to true
concise When set to true, this presents less information. (e.g.: shorter summary, no precipitation accumulation, no wind gusts, etc.)

Type Boolean
Defaults to true
iconset Which icon set to use. See below for previews of the icon sets.

Type String
Defaults to 1c
useAnimatedIcons Whether to use the Dark Sky's own animated icon set. When set to true, this will override your choice for iconset. However, flat icons will still be used in some instances. For example if you set the animateMainIconOnly parameter to true, daily and hourly forecasts will not be animated and instead will use your choice for iconset. Inline icons (i.e. used to prefix precipitation and wind information) will always be flat. A good iconset match for the animated set is 1c.

Type Boolean
Defaults to true
animateMainIconOnly When set to true, only the main current conditions icon is animated. The rest use your choice for iconset (1c is a good match for the animated icon). If you are running on a low-powered device like a Raspberry Pi, performance may suffer if you set this to false. In my testing on a Pi 3b, enabling this ramped up CPU temperature by 15° - 20°, and fade transitions were not smooth.

Type Boolean
Defaults to true
showInlineIcons Whether to prefix wind and precipitation information with an icon. Only affects the tiled layout.

Type Boolean
Defaults to true
forecastLayout Can be set to tiled or table. How to display hourly and forecast information. See below for screenshot examples of each.

Type String
Defaults to tiled
label_maximum The label you wish to display for prefixing wind gusts.

Type String
Defaults to "max".
label_high The label you wish to display for prefixing high temperature.

Type String
Defaults to "H".
label_low The label you wish to display for prefixing low temperature.

Type String
Defaults to "L".
label_timeFormat How you want the time formatted for hourly forecast display. Accepts any valid moment.js format (https://momentjs.com/docs/#/displaying/format/). For example, specify short 24h format with "k[h]" (e.g.: 14h)

Type String
Defaults to "h a" (e.g.: 9 am)
label_days How you would like the days of the week displayed for daily forecasts. Assumes index 0 is Sunday.

Type Array of Strings
Defaults to ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"]
label_ordinals How you would like wind direction to be displayed. Assumes index 0 is North and proceeds clockwise.

Type Array of Strings
Defaults to ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]

Sample Configuration

{
  module: "MMM-DarkSkyForecast",
  header: "Weather",
  position: "top_right",
  classes: "default everyone",
  disabled: false,
  config: {
    apikey: "SUPER SECRET!!!",
    latitude: "51.506130",
    longitude: "-0.090270",      
    iconset: "4c",
    concise: false,
    forecastLayout: "table"
  }
},

Icon Sets

Icon Sets

Layouts

Layouts

Styling

This module is set to be 300px wide by default. If you wish to override it, you can add the following to your custom.css file:

.MMM-DarkSkyForecast .module-content {
  width: 500px; /* adjust this to taste */
}

Most important elements of this module have one or more class names applied. Examine the MMM-DarkSkyForecast.css or inspect elements directly with your browser of choice to determine what class you would like to override.

For Module Developers

This module broadcasts a notification when it recieves a weather update. The notification is DARK_SKY_FORECAST_WEATHER_UPDATE and the payload contains Dark Sky's JSON weather forecast object. For details on the weather object, see https://darksky.net/dev/docs.

Attributions

Skycons - Animated icon set by Dark Sky
http://darkskyapp.github.io/skycons/
(using the fork created by Maxime Warner that allows individual details of the icons to be coloured
https://github.com/maxdow/skycons)

Climacons by Adam Whitcroft
http://adamwhitcroft.com/climacons/

Free Weather Icons by Svilen Petrov
https://www.behance.net/gallery/12410195/Free-Weather-Icons

Weather Icons by Thom
(Designed for DuckDuckGo)
https://dribbble.com/shots/1832162-Weather-Icons

Sets 4 and 5 were found on Graphberry, but I couldn't find the original artists.
https://www.graphberry.com/item/weather-icons
https://www.graphberry.com/item/weathera-weather-forecast-icons

Some of the icons were modified to better work with the module's structure and aesthetic.

Weather data provided by OpenWeather
https://openweathermap.org

About

Magic Mirror module to display weather information using the Dark Sky API

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 71.5%
  • HTML 16.7%
  • CSS 11.8%