Home

Awesome

MMM-mqtt

This is an extension for the MagicMirror². It provides the ability to subscribe to MQTT topics and display them.

Installation

  1. Ensure that you have the necessary libraries/clients for mqtt installed on the computer that will be running this extension. (For example, running sudo apt-get install mosquitto mosquitto-clients on Debian-based distributions.)
  2. Navigate into your MagicMirror's modules folder and execute git clone https://github.com/javiergayala/MMM-mqtt.git. A new folder will appear, likely called MMM-mqtt. Navigate into it.
  3. Execute npm install to install the node dependencies.

Using the module

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

modules: [
	{
		module: 'MMM-mqtt',
		position: 'top_right',	// This can be any of the regions. Best results in left or right regions.
		header: 'Living Room Temperature', // This is optional
		config: {
			// See 'Configuration options' for more information.
		}
	}
]

Configuration options

The following options can be configured:

OptionDescription
mqttServerConnection string for the server to connect to (e.g. mqtt://localhost) See: Server URL
loadingTextText to display while waiting for data to load
topicMQTT Topic to subscribe to on the server (sensors/temperature/livingroom)
showTitleBoolean to show/hide a title (default: false)
titleTitle to show if showTitle is true
intervalRefresh interval, not including MQTT subscription deliveries. (default: 300000)
postTextText to append after the data received from MQTT (default: '')
modePossible values: send or receive (default: receive)
roundValueRounds displayed value to specified decimals (default: false)
decimalsnumber of decimals to round with roundValue (default: 2)

Server URL

The server URL can be configured with all options supported by URL.parse. The format used is

   mqtt:    //    user   :   pass   @ some.host.com : 1883
| protocol |  | username | password |   hostname    | port |

Supported protocols include:

Mode

By default the module will receive MQTT messages from the configured topic and display these. MMM-mqtt can also be used to broadcast local MagicMirror² notifications from modules to an MQTT topic. A sending module doesn't have to be displayed. A sample minimal config for sending:

{
	module: "MMM-mqtt",
	config: {
		mqttServer: "mqtts://localhost:8883",
		topic: "home/living/magicmirror",
		mode: "send"
	}
}

Dependencies

Contributing Guidelines

Contributions of all kinds are welcome, not only in the form of code but also with regards bug reports and documentation.

Please keep the following in mind:

The MIT License (MIT)

Copyright © 2016 Javier G. Ayala

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.