/MMM-envcan

Environment Canada Weather module for MagicMirror2

Primary LanguageJavaScriptMIT LicenseMIT

Module: envcan

This module displays weather forecast based on an RSS feed. Scrolling through forecast entries happens time-based (updateInterval), but can also be controlled by sending news feed specific notifications to the module.

This module is built upon the default newsfeed module from MagicMirror written by Michael Teeuw http://michaelteeuw.nl

The numeric code for your Canadian city can be found by choosing your city forecast from https://weather.gc.ca/canada_e.html, and then copying the "Follow Weather" RSS link and placing it in your config.js file as shown below.

Screenshot

Winnipeg, MB Forecast Screenshot

Using the module

Configuration

To use this module, add it to the modules array in the config/config.js file:

modules: [
		{
			module: "MMM-envcan",
			position: "top_center",
			config: {
				feeds: [
					{
						title: "EnvCan Winnipeg",
						url: "https://weather.gc.ca/rss/city/mb-38_e.xml"
					}
				],
				showSourceTitle: false,
				showPublishDate: true,
				showDescription: true,
				wrapDescription: true,
				maxNewsItems: 6,
				reloadInterval: 900000 // 15 minutes
			}
		},
]

Notifications

Interacting with the module

MagicMirror's notification mechanism allows to send notifications to the newsfeed module. The following notifications are supported:

Notification Identifier Description
ARTICLE_NEXT Shows the next news title (hiding the summary or previously fully displayed article)
ARTICLE_PREVIOUS Shows the previous news title (hiding the summary or previously fully displayed article)
ARTICLE_MORE_DETAILS When received the first time, shows the corresponding description of the currently displayed news title.
The module expects that the module's configuration option showDescription is set to false (default value).

When received a second consecutive time, shows the full news article in an IFRAME.
This requires that the news page can be embedded in an IFRAME, e.g. doesn't have the HTTP response header X-Frame-Options set to e.g. DENY.

When received the next consecutive times, reloads the page and scrolls down by scrollLength pixels to paginate through the article.
ARTICLE_LESS_DETAILS Hides the summary or full news article and only displays the news title of the currently viewed news item.
ARTICLE_TOGGLE_FULL Toogles article in fullscreen.

Note the payload of the sent notification event is ignored.

Example

The following example shows how the next news article title can be displayed on the MagicMirror.

this.sendNotification('ARTICLE_NEXT');

newsfeed specific notification emitting modules

The third party MMM-Gestures module supports above notifications when moving your hand up, down, left or right in front of a gesture sensor attached to the MagicMirror. See module's readme for more details.

Configuration options

The following properties can be configured:

Option Description
feeds An array of feed urls that will be used as source.
More info about this object can be found below.
Default value: [{ title: "New York Times", url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml", encoding: "UTF-8" }]
You can add reloadInterval option to set particular reloadInterval to a feed.
showSourceTitle Display the title of the source.

Possible values: true or false
Default value: true
showPublishDate Display the publish date of an headline.

Possible values: true or false
Default value: true
showDescription Display the description of an item.

Possible values: true or false
Default value: false
wrapTitle Wrap the title of the item to multiple lines.

Possible values: true or false
Default value: true
wrapDescription Wrap the description of the item to multiple lines.

Possible values: true or false
Default value: true
truncDescription Truncate description?

Possible values: true or false
Default value: true
lengthDescription How many characters to be displayed for a truncated description?

Possible values: 1 - 500
Default value: 400
hideLoading Hide module instead of showing LOADING status.

Possible values: true or false
Default value: false
reloadInterval How often does the content needs to be fetched? (Milliseconds)

Possible values: 1000 - 86400000
Default value: 300000 (5 minutes)
updateInterval How often do you want to display a new headline? (Milliseconds)

Possible values:1000 - 60000
Default value: 10000 (10 seconds)
animationSpeed Speed of the update animation. (Milliseconds)

Possible values:0 - 5000
Default value: 2500 (2.5 seconds)
maxNewsItems Total amount of news items to cycle through. (0 for unlimited)

Possible values:0 - ...
Default value: 0
ignoreOldItems Ignore news items that are outdated.

Possible values:true or false
Default value: false
ignoreOlderThan How old should news items be before they are considered outdated? (Milliseconds)

Possible values:1 - ...
Default value: 86400000 (1 day)
removeStartTags Some newsfeeds feature tags at the beginning of their titles or descriptions, such as [VIDEO]. This setting allows for the removal of specified tags from the beginning of an item's description and/or title.

Possible values:'title', 'description', 'both'
startTags List the tags you would like to have removed at the beginning of the feed item

Possible values: ['TAG'] or ['TAG1','TAG2',...]
removeEndTags Remove specified tags from the end of an item's description and/or title.

Possible values:'title', 'description', 'both'
endTags List the tags you would like to have removed at the end of the feed item

Possible values: ['TAG'] or ['TAG1','TAG2',...]
prohibitedWords Remove news feed item if one of these words is found anywhere in the title (case insensitive and greedy matching)

Possible values: ['word'] or ['word1','word2',...]
scrollLength Scrolls the full news article page by a given number of pixels when a ARTICLE_MORE_DETAILS notification is received and the full news article is already displayed.

Possible values: 1 or 10000
Default value: 500
logFeedWarnings Log warnings when there is an error parsing a news article.

Possible values: true or false
Default value: false
stickyCurrentConditions Always keep the current conditions on top`

The feeds property contains an array with multiple objects. These objects have the following properties:

Option Description
title The name of the feed source to be displayed above the items.

This property is optional.
url The url of the Atom feed used for the forecast.

Example: 'https://weather.gc.ca/rss/city/mb-38_e.xml'
encoding The encoding of the news feed.

This property is optional.
Possible values:'UTF-8', 'ISO-8859-1', etc ...
Default value: 'UTF-8'

Feeds can be found on the https://weather.gc.ca site under the rss icon. Here are the feeds for some Canadian cities:

City Feed URL
St. John's 'https://weather.gc.ca/rss/city/nl-24_e.xml'
Halifax 'https://weather.gc.ca/rss/city/ns-19_e.xml'
Fredericton 'https://weather.gc.ca/rss/city/nb-29_e.xml'
Montreal 'https://weather.gc.ca/rss/city/qc-147_e.xml'
Quebec 'https://weather.gc.ca/rss/city/qc-133_e.xml'
Ottawa 'https://weather.gc.ca/rss/city/on-118_e.xml'
Toronto 'https://weather.gc.ca/rss/city/on-143_e.xml'
Thunder Bay 'https://weather.gc.ca/rss/city/on-100_e.xml'
Winnipeg 'https://weather.gc.ca/rss/city/mb-38_e.xml'
Regina 'https://weather.gc.ca/rss/city/sk-32_e.xml'
Saskatoon 'https://weather.gc.ca/rss/city/sk-40_e.xml'
Calgary 'https://weather.gc.ca/rss/city/ab-52_e.xml'
Edmonton 'https://weather.gc.ca/rss/city/ab-50_e.xml'
Vancouver 'https://weather.gc.ca/rss/city/bc-74_e.xml'
Victoria 'https://weather.gc.ca/rss/city/bc-85_e.xml'