The MMM-Farevarsel module is a MagicMirror² addon. This module displays weather alerts (text based) from the Norwegian Meteorological Institute (https://api.met.no/). I used TuxDiver's MMM-Rest as a starting point for this module.
The alerts only cover Norwegian areas and are (therefore) only in Norwegian
The alert data is from MET Norway and is licensed under the Norwegian Licence for Open Government Data (NLOD) 2.0 and Creative Commons 4.0 BY International.
Run the following commands
cd ~/MagicMirror/modules
git clone https://github.com/mabahj/MMM-Farevarsel
cd MMM-Farevarsel
npm installDo not forget the "npm install" at the end - it fetches the required sub dependencies.
cd ~/MagicMirror/modules/MMM-Farevarsel
git pull
npm install- 2026-10-25: Fixed red alerts showing as yellow and missing color on marine alerts. Updated county codes and general improvements to README.
- 2025-05-26: Added support for lat/lon, which can be used instead of county.
- 2024-09-10: Review: Remove deprecated dependency 'request' and little changes like formatting and typos. No functional changes.
- 2024-09-09: Updated to 2.0 API, the previous was depreciated. Added user agent, as required by met.no. Added some county information in the README.md and improved information when it failed (server side error log).
- 2019-11-11: First attempt at creating a (this) MagicMirror Module.
- I am not a software developer. There are probably a lot of things that can fail. But it works just fine for me. PRs welcome. :)
- This module shows the alerts that are valid for your location (lat/lon) or county. Your weather app (e.g. Yr) may also show alerts for neighbouring areas, so it may list alerts that this module does not show.
To use this module, add it to the modules array in the config/config.js file:
{
module: 'MMM-Farevarsel',
position: 'top_bar', // This can be any of the regions. I think.
config: {
//county: '02', // See below for counties.
lat: 61.6360, lon: 8.3146, // Galdhøpiggen. Use county or lat/lon.
colorBackground: true,
},
},When there are no alerts for your location, the module hides itself. Most of the time the module is therefore not visible, which is normal.
To check that the module works, you can temporarily point it to met.no's test feed by adding this to config:
url: 'https://api.met.no/weatherapi/metalerts/2.0/test.rss',Note that the test feed may also be empty. Remove the url line again when you are done testing.
The following properties can be configured. None of these are required, but lat/lon is recommended, otherwise you get alerts for Oslo.
| Option | Default | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lat |
Latitude position for alerts. Only Norway is supported. Use lat/lon or county, not both. Example: 61.6360
|
|||||||||||||||||||||||||||||||||
lon |
Longitude position for alerts. Only Norway is supported. Use lat/lon or county, not both. Example: 8.3146
|
|||||||||||||||||||||||||||||||||
county |
'03' |
(Latitude and longitude is recommended instead of county.) The county (in Norway) to fetch weather alerts for. Two digits are required, so prefix with 0 if single digit. See https://data.norge.no/datasets/dd05acaa-1c89-4139-8612-0ad10e75d6a6 for a list of counties. Default is '03' for Oslo. This field is a string, so it must be enclosed in quotation marks: E.g. '02' or “02”.
|
||||||||||||||||||||||||||||||||
colorBackground |
true |
Options: true or false Show or do not show a background color matching the official alert level. Yellow, Orange or Red. |
||||||||||||||||||||||||||||||||
updateInterval |
1800000 |
How often to fetch alerts, in milliseconds. Default is 30 minutes. Please do not set this much lower, met.no is a free service. Example: 3600000 (60 min)
|
||||||||||||||||||||||||||||||||
initialLoadDelay |
1000 |
How long to wait for the first load Example: 60000 (60 s)
|
||||||||||||||||||||||||||||||||
animationSpeed |
2000 |
Fadeover effect for dom updates Example: 1000
|
||||||||||||||||||||||||||||||||
debug |
false |
Options: true or false Write extra log messages to the browser console. |
||||||||||||||||||||||||||||||||
url |
(Do not set this) | Only for testing, see Using the module: 'https://api.met.no/weatherapi/metalerts/2.0/test.rss' |
