MagicMirrorModule for fetching REST data and displaying them on the mirror
JavaScript CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
MMM-Rest.css
MMM-Rest.js
README.md
node_helper.js
package.json

README.md

Module: MMM-Rest

The MMM-Rest module is a MagicMirror addon. This module collects data via HTTP calls and displays it on your mirror in a table.

Rest Displays

Installation

  1. Navigate into your MagicMirror's 'modules' folder and execute 'git clone https://github.com/Tuxdiver/MMM-Rest.git'
  2. cd 'cd MMM-Rest'
  3. Execute 'npm install' to install the node dependencies.

Changelog

2016-10-27: incompatible changes: the "suffix" and "digits" parameters are removed and replaced by a "format" parameter! Please check your config! 2018-02-02: added ranges to format parameter

Known Issues

  • had a problem with remote URLs an AJAX: changed to node_helper.js to collect data

Using the module

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

modules: [
	{
		module: 'MMM-Rest',
		position: 'bottom_right',	// This can be any of the regions.
									// Best results in one of the side regions like: top_left
        config: {
                debug: false,
                mappings: {
                    on_off: {
                        true: 'on',
                        false: 'off',
                    },
                    temperature: {
                        1: 'cold',
                        2: 'warm',
                        3: 'HOT',
                    },
                },
                sections: [
                {
                    format: '%.1f<span class="wi wi-celsius"></span>',
                    url: 'https://www.dirk-melchers.de/echo.php?text=22.54',
                },
                {
                    format: [
                        { range: [, 10], format: '<span style="color:green">%d</span>'},
                        { range: [10, 20], format: '<span style="color:yellow">%d</span>'},
                        { range: [30, ], format: '<span style="color:red">%d</span>'},
                        { string: 'HOT', format: '<span style="color:red">%d</span>'},
                        { format: '%d'}
                    ],
                    url: 'https://www.dirk-melchers.de/echo.php?text=59.1',
                },
                {
                    format: '%s',
                    mapping: 'temperature',
                    url: 'https://www.dirk-melchers.de/echo.php?text=2',
                },
                {
                    format: '%d<span class="wi wi-humidity"></span>',
                    url: 'https://www.dirk-melchers.de/echo.php?text=62.1',
                },
                {
                    format: 'Lights %s',
                    mapping: 'on_off',
                    url: 'https://www.dirk-melchers.de/echo.php?text=true',
                },
            ],
            output: [
                ['Livingroom','@1','@2'],
                ['Kitchen','@3','@4'],
                ['Fridge','@5'],
            ],
	    },
	}
]

Configuration options

The following properties can be configured:

Option Description
sections sections is an array of hashes for the REST endpoints to connect to
Option Description
format If it is a strint: sprintf() format
Could also be an array of hashes. The array is processed from top to bottom and first match wins. The last entry could be a default without "range". Leaving one value of the range empty means "ignore this bound".
You could use "string" instead of "range" to match the value against the parameter of the string.
mapping Map the value againt a defined mapping
url The url to call. It has to return a single integer / floating point value
mappings mappings is an hash of hashes for the mapping of values to other values
Option Description
NAME_OF_MAPPING Name of mapping will be referenced by sections -> mapping
values hash of key / values to map from / to
output control the output table for the display. Has to be a 2-dimensional array representing the rows and the columns of the output
A cell containing a '@' followed by a number represents the section id (starting by 1) of the REST Urls
updateInterval How often this refreshes

Example: 60000
Default value: 60000
initialLoadDelay How long to wait for the first load

Example: 60000
Default value: 0
animationSpeed Fadeover effect for dom updates

Example: 1000
Default value: 2000
debug Log messages to Log.info / console

Example: true
Default value: false