aSouchereau / MMM-CanadianPublicWeatherAlerts

Gets weather watches, warnings, and advisories for user specified regions. Using data published by Environment Canada.
MIT License
3 stars 0 forks source link

MMM-CanadianPublicWeatherAlerts

A module for MagicMirror to display Canadian Public Weather Alerts provided by Environment Canada.

Description:

Gets weather watches, warnings, and advisories for user specified regions. Using data published by Environment Canada.

Installation

  1. From your modules folder, clone the repository by running git clone https://github.com/aSouchereau/MMM-CanadianPublicWeatherAlerts.git
  2. Install the required dependencies by running npm install
  3. Add the module to the mirror's config. (See below)
  4. Find the code for your region(s) and enter them into the config file.
{
  module: "MMM-CanadianPublicWeatherAlerts",
  position: "top_center",
  config: {
      lang: 'en',
      regions: [
        {
          code: "on16"
        },
        {
          code: "on17"
        },
        {
          code: "bc46"
        }
      ],
      updateInterval: 60000,
      animationSpeed: 1000,
      displayInterval: 5000
  }
}

Options

Option Description Default Required
lang Sets the language the alerts are displayed in. English and French only. Set as either en or fr. en
regions Sets the regions this module will display alerts for. See instructions below to find the region code for your area. x
updateInterval Sets the interval between each alert update. By default, this module will get new alert data every 60 seconds. 60000
displayInterval Sets the amount of time each alert is displayed for. Default value is 5 seconds. 5000
animationSpeed Sets the speed of the cross-fade between each alert. Set to 0 to disable. Default value is 1 second. 1000
showNoAlertsMsg If set to true, the module will display a "No alerts in effect" message for each region. false
periodicSync If set to true, the module will periodically resend the config and request a new update from the server. This is helpful for server only installations where a client may become "out of sync" if the server restarts. false
syncInterval Sets the amount of time between each sync. By default (if enabled), the module will sync with the server once every 10 minutes. 600000

Regions

** Note: Environment Canada has recently redesigned their weather alerts system. It may now be more difficult to find your region code from the alerts page. You should now use the atom feeds page linked below.

Environment Canada publishes weather alerts for regions across the country. Regions are represented by a region code that follows the format of xx00 or xxrm00.

To find the code for your desired region visit Env Canada Atom Feeds and scroll down to search for it in the table.

The region code can be found at the end of the url in the Atom URL column.

Copy the region code into your config. Repeat for any other regions you want to add.

{
  module: "MMM-CanadianPublicWeatherAlerts",
  position: "top_center",
  config: {
      lang: 'en',
      regions: [
        {
          code: "onrm26"
        },
        {
          code: "on17"
        },
        {
          code: "bc46"
        }
      ],
      updateInterval: 60000,
      animationSpeed: 1000,
      displayInterval: 5000
  }
}

Intervals

updateInterval

displayInterval and animationSpeed

displayInterval is the amount of time a single alert is displayed for, not including the animation speed. For example:

syncInterval

Custom Styling

Each element is assigned a class that denotes its type. You can target this class in the mirror's custom.css file.

Element Class
Title alert-title
Location alert-region
Time Since alert-time