{"id":13830262,"url":"https://github.com/Tuxdiver/MMM-Rest","last_synced_at":"2025-07-09T11:32:32.872Z","repository":{"id":61696539,"uuid":"66913778","full_name":"Tuxdiver/MMM-Rest","owner":"Tuxdiver","description":" MagicMirror² addon for fetching REST data and displaying it on the mirror","archived":false,"fork":false,"pushed_at":"2024-05-08T07:00:49.000Z","size":124,"stargazers_count":19,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-08-04T10:02:48.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tuxdiver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-30T06:38:14.000Z","updated_at":"2024-05-08T07:01:36.000Z","dependencies_parsed_at":"2024-03-27T21:37:18.216Z","dependency_job_id":null,"html_url":"https://github.com/Tuxdiver/MMM-Rest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tuxdiver%2FMMM-Rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tuxdiver%2FMMM-Rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tuxdiver%2FMMM-Rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tuxdiver%2FMMM-Rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tuxdiver","download_url":"https://codeload.github.com/Tuxdiver/MMM-Rest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225539366,"owners_count":17485313,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T10:00:57.964Z","updated_at":"2024-11-20T11:30:35.040Z","avatar_url":"https://github.com/Tuxdiver.png","language":"JavaScript","funding_links":[],"categories":["Home Automation \u0026 Notifications"],"sub_categories":[],"readme":"# Module: MMM-Rest\n\nThe `MMM-Rest` module is a [MagicMirror²](https://github.com/MagicMirrorOrg/MagicMirror) addon.\nThis module collects data via HTTP calls and displays it on your mirror in a table.\n\n![Rest Displays](screenshot.png)\n\n## Installation\n\n1. Navigate into your MagicMirror's `modules` folder and execute `git clone https://github.com/Tuxdiver/MMM-Rest`\n2. cd `cd MMM-Rest`\n3. Execute `npm install` to install the node dependencies.\n\n## Changelog\n\n- 2016-10-27: incompatible changes: the \"suffix\" and \"digits\" parameters are removed and replaced by a \"format\" parameter! Please check your config!\n- 2018-02-02: added ranges to format parameter\n- 2024-03-21: added the ability to place multiple instances of the module into config files\n- 2024-03-22: Added the ability to specify and customize display of DateTime objects\n- 2024-03-22: Added the ability to transform REST results before displaying\n- 2024-05-06: Added new optional variable `forceAlign` for more customizable alignment \n\n## Using the module\n\nTo use this module, add it to the modules array in the `config/config.js` file:\n\n````javascript\nmodules: [\n    {\n        module: 'MMM-Rest',\n        position: 'bottom_right',    // This can be any of the regions.\n                                     // Best results in one of the side regions like: top_left\n        config: {\n                debug: false,\n\t\tforceAlign: false,\n\t\tmappings: {\n                    on_off: {\n                        true: 'on',\n                        false: 'off',\n                    },\n                    temperature: {\n                        1: 'cold',\n                        2: 'warm',\n                        3: 'HOT',\n                    },\n                },\n                sections: [\n                {\n                    format: '%.1f\u003cspan class=\"wi wi-celsius\"\u003e\u003c/span\u003e',\n                    url: 'https://www.dirk-melchers.de/echo.php?text=22.54',\n                },\n                {\n                    format: [\n                        { range: [, 10], format: '\u003cspan style=\"color:green\"\u003e%d\u003c/span\u003e'},\n                        { range: [10, 20], format: '\u003cspan style=\"color:yellow\"\u003e%d\u003c/span\u003e'},\n                        { range: [30, ], format: '\u003cspan style=\"color:red\"\u003e%d\u003c/span\u003e'},\n                        { string: 'HOT', format: '\u003cspan style=\"color:red\"\u003e%d\u003c/span\u003e'},\n                        { format: '%d'}\n                    ],\n                    url: 'https://www.dirk-melchers.de/echo.php?text=59.1',\n                },\n                {\n                    format: '%s',\n                    mapping: 'temperature',\n                    url: 'https://www.dirk-melchers.de/echo.php?text=2',\n                },\n                {\n                    format: '%d\u003cspan class=\"wi wi-humidity\"\u003e\u003c/span\u003e',\n                    url: 'https://www.dirk-melchers.de/echo.php?text=62.1',\n                },\n                {\n                    format: 'Lights %s',\n                    mapping: 'on_off',\n                    url: 'https://www.dirk-melchers.de/echo.php?text=true',\n                },\n\t\t{\n                    format: [\n                        { dateOptions: { weekday: 'long', month: 'long', day: 'numeric', hour: 'numeric', minute: '2-digit', hour12: true }, format: '\u003cspan style=\"color:green\"\u003e%s\u003c/span\u003e'},\n                    ],\n                    url: 'https://www.dirk-melchers.de/echo.php?text=2024-03-22T00:11:05.000+0000',\n                },\n                {\n                    format: [\n                        { range: [, 1000], format: '\u003cspan style=\"color:green\"\u003e%d W\u003c/span\u003e'},\n                        { range: [1000, 1000000], format: '%.1f kW', transform: 'value/1000'}\n                        { format: '%.1f MW', transform: 'value/1000000'}\n                    ],\n                    url: 'https://www.dirk-melchers.de/echo.php?text=10005',\n                },\n            ],\n            output: [\n                ['Livingroom','@1','@2'],\n                ['Kitchen','@3','@4'],\n                ['Fridge','@5'],\n                ['Last Updated','@6'],\n                ['Solar Production','@7'],\n            ],\n        },\n    }\n]\n````\n\n## Configuration options\n\nThe following properties can be configured:\n\n\u003ctable width=\"100%\"\u003e\n    \u003c!-- why, markdown... --\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth\u003eOption\u003c/th\u003e\n            \u003cth width=\"100%\"\u003eDescription\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003cthead\u003e\n    \u003ctbody\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003esections\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003esections is an array of hashes for the REST endpoints to connect to\u003cbr\u003e\n            \u003ctable\u003e\n                \u003cthead\u003e\n                    \u003ctr\u003e\n                        \u003cth\u003eOption\u003c/th\u003e\n                        \u003cth width=\"100%\"\u003eDescription\u003c/th\u003e\n                    \u003c/tr\u003e\n                \u003cthead\u003e\n                \u003ctbody\u003e\n                    \u003ctr\u003e\n                        \u003ctd valign=\"top\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/td\u003e\n                        \u003ctd\u003e- If it is a string: sprintf() format\u003cbr\u003e\n                        - Could also be an array of hashes. The array is processed from top to bottom and first match wins. \n\t\t\t\t\u003cbr\u003eThe last entry could be a default without \"range\". Leaving one value of the range empty means \n\t\t\t\t\u003cbr\u003e\"ignore this bound\".\u003cbr\u003e\n                        - You could use \"string\" instead of \"range\" to match the value against the parameter of the string.\u003cbr\u003e\n\t\t\t- Finally, you could use \"dateOptions\" instead of \"range\" or \"string\" to specify that the expected \n\t\t\t\t\u003cbr\u003evalue is an ISO 8601 DateTime object (may work for other date formats as well, as long as \n\t\t\t\t\u003cbr\u003ethe javascript function `new Date()` takes that format), and describe what format you want the \n\t\t\t\t\u003cbr\u003edate displayed in.  Formatting options described here \n\t\t\t\t\u003cbr\u003ehttps://stackoverflow.com/questions/3552461/how-do-i-format-a-date-in-javascript. \u003cbr\u003e \n\t\t\t- You may also add a `transform` function to convert the value before displaying it.  Use a string that \n\t\t\t\t\u003cbr\u003eis a common mathematical function with the value of the raw REST data is `value`.  E.g., `value/1000` \n\t\t\t\t\u003cbr\u003ewill divide the raw value by 1000 before displaying.  Useful for converting units.  Note:  transform \n\t\t\t\t\u003cbr\u003ehappens \u003ci\u003eafter\u003c/i\u003e any range is matched.\n                        \u003c/td\u003e\n                    \u003c/tr\u003e\n                    \u003ctr\u003e\n                        \u003ctd valign=\"top\"\u003e\u003ccode\u003emapping\u003c/code\u003e\u003c/td\u003e\n                        \u003ctd\u003eMap the value againt a defined mapping\u003c/td\u003e\n                    \u003c/tr\u003e\n                    \u003ctr\u003e\n                        \u003ctd valign=\"top\"\u003e\u003ccode\u003eurl\u003c/code\u003e\u003c/td\u003e\n                        \u003ctd\u003eThe url to call. It has to return a single integer / floating point value\u003c/td\u003e\n                    \u003c/tr\u003e\n                \u003c/tbody\u003e\n            \u003c/table\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003emappings\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003emappings is an hash of hashes for the mapping of values to other values\u003cbr\u003e\n            \u003ctable\u003e\n                \u003cthead\u003e\n                    \u003ctr\u003e\n                        \u003cth\u003eOption\u003c/th\u003e\n                        \u003cth width=\"100%\"\u003eDescription\u003c/th\u003e\n                    \u003c/tr\u003e\n                \u003cthead\u003e\n                \u003ctbody\u003e\n                    \u003ctr\u003e\n                        \u003ctd valign=\"top\"\u003e\u003ccode\u003eNAME_OF_MAPPING\u003c/code\u003e\u003c/td\u003e\n                        \u003ctd\u003eName of mapping will be referenced by sections -\u003e mapping\u003c/td\u003e\n                    \u003c/tr\u003e\n                    \u003ctr\u003e\n                        \u003ctd valign=\"top\"\u003e\u003ccode\u003evalues\u003c/code\u003e\u003c/td\u003e\n                        \u003ctd\u003ehash of key / values to map from / to\u003c/td\u003e\n                    \u003c/tr\u003e\n                \u003c/tbody\u003e\n            \u003c/table\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003eoutput\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003econtrol the output table for the display.\n            Has to be a 2-dimensional array representing the rows and the columns \u003cbr\u003eof the output\n            \u003cbr\u003eA cell containing a '@' followed by a number represents the section id (starting by 1) of the REST Urls\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003eupdateInterval\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003eHow often this refreshes\u003cbr\u003e\n                \u003cbr\u003e\u003cb\u003eExample:\u003c/b\u003e \u003ccode\u003e60000\u003c/code\u003e\n                \u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e60000\u003c/code\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003einitialLoadDelay\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003eHow long to wait for the first load\u003cbr\u003e\n                \u003cbr\u003e\u003cb\u003eExample:\u003c/b\u003e \u003ccode\u003e60000\u003c/code\u003e\n                \u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e0\u003c/code\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003eanimationSpeed\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003eFadeover effect for dom updates\u003cbr\u003e\n                \u003cbr\u003e\u003cb\u003eExample:\u003c/b\u003e \u003ccode\u003e1000\u003c/code\u003e\n                \u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003e2000\u003c/code\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n\t\u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003eforceAlign\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003eBoolean.  Describes the alignment behavior of the table\u003cbr\u003e\n\t\t\u003ccode\u003efalse\u003c/code\u003e will align description cells to the left and variable cells (e.g., \u003ccode\u003e@1\u003c/code\u003e) to the right.\n\t\t\u003cbr\u003e \u003ccode\u003etrue\u003c/code\u003e will align all cells in the leftmost column to the left and all other cells to the right.\n\t\t\u003cbr\u003e\n                \u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd valign=\"top\"\u003e\u003ccode\u003edebug\u003c/code\u003e\u003c/td\u003e\n            \u003ctd\u003eLog messages to Log.info / console\u003cbr\u003e\n                \u003cbr\u003e\u003cb\u003eExample:\u003c/b\u003e \u003ccode\u003etrue\u003c/code\u003e\n                \u003cbr\u003e\u003cb\u003eDefault value:\u003c/b\u003e \u003ccode\u003efalse\u003c/code\u003e\n            \u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTuxdiver%2FMMM-Rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTuxdiver%2FMMM-Rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTuxdiver%2FMMM-Rest/lists"}