This is a module for the MagicMirror. It adds a Timer that can be controlled by API or Notifications.
The Timer will only be shown while is running. Only one timer can run at a time. Possible actions are start a timer, update and stop a running timer.
- Go to your MagicMirror's
modules
folder. - Run
git clone https://github.com/luk-schweizer/MMM-timer.git
.
Add the module to the configuration file config/config.js
:
modules: [
{
module: 'MMM-timer',
config: {
timeToHideTimerWhenCompleteMs: 10000
}
}
]
The following properties can be configured:
Option | Description |
---|---|
timeToHideTimerWhenCompleteMs |
Time in miliseconds that the Timer will remain on screen before being hidden once the Timer finished. Type: int
Default value: 10000
|
width |
Width of the Timer. Type: string
Default value: 500px
|
height |
Height of the Timer. Type: string
Default value: 500px
|
strokeWidth |
Stroke width of the Timer circumference. Type: string
Default value: 7px
|
fontSize |
Font Size of the timer numbers. Type: string
Default value: 30
|
The API exposed by the module is:
http://{MagicMirrorServerHost}/MMM-timer/timer
Where MagicMirrorServerHost
is the host of the Magic Mirror server or localhost
if hitting locally.
The following list contains the different HTTP methods that can be used with the API above:
HTTP Method | Body (application/json) | Response | Description |
---|---|---|---|
POST
|
{"timeLimitMs": 1000}
|
|
Starts and shows the timer with the specific time limit. No action if a timer is already running. |
PUT
|
{"timeLimitMs": 2000}
|
|
Updates the running timer with the specific time limit. No action is made if no timer is running. |
DELETE
|
none
|
|
Stops and hide the running timer with the specific time limit. No action is made if no timer is running. |
List of notifications that the module can handle:
Notification | Payload | Description |
---|---|---|
START_TIMER |
{timeLimitMs: 1000}
|
Starts and shows the timer with the specific time limit. No action if a timer is already running. |
UPDATE_TIMER |
{timeLimitMs: 2000}
|
Updates the running timer with the specific time limit. No action is made if no timer is running. |
ADD_TIMER |
{timeMs: 2000}
|
Adds time to the running timer. No action is made if no timer is running. |
STOP_TIMER |
none
|
Stops and hide the running timer with the specific time limit. No action is made if no timer is running. |