Skip to content

luk-schweizer/MMM-timer

Repository files navigation

MMM-timer

coverage GitHub release (latest by date)

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.

Installation

  1. Go to your MagicMirror's modules folder.
  2. Run git clone https://github.com/luk-schweizer/MMM-timer.git.

Using the module

Add the module to the configuration file config/config.js:

modules: [
	{
		module: 'MMM-timer',
		config: {
			timeToHideTimerWhenCompleteMs: 10000
		}
	}
]

Configuration options

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

API

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}
  • 200 (Request processed): Create successfully
  • 400 (timeLimitMs is undefined): timeLimitMs is not present in the body, request is discarded
  • 409 (A timer is already running): A timer is running, request is discarded
Starts and shows the timer with the specific time limit. No action if a timer is already running.
PUT {"timeLimitMs": 2000}
  • 200 (Request processed): Update successfully
  • 400 (timeLimitMs is undefined): timeLimitMs is not present in the body, request is discarded
  • 409 (A timer is not running): A timer is not running, request is discarded
Updates the running timer with the specific time limit. No action is made if no timer is running.
DELETE none
  • 200 (Request processed): Delete successfully
  • 409 (A timer is not running): A timer is not running, request is discarded
Stops and hide the running timer with the specific time limit. No action is made if no timer is running.

Notifications

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published