TOPIC MOVED. PLEASE FOLLOW THE LINK BELOW FOR THE MODULE UPDATES, INQUIRIES, ETC
[MMM-MQTTbridge] A module to publish and receive MQTT messages.
MMM-MQTTbridge
https://github.com/Tom-Hirschberger/MMM-MQTTbridge
MMM-MQTTbridge allows you to integrate your MagicMirror into your smart home system via MQTT protocol and manage MagicMirror via MQTT messages by converting them into MM Notifications and vise verse - listen to your MM’s Notifications and convert them into MQTT mesages.
So, this module for MagicMirror do the following:
- Listens to MQTT messages from your MQTT broker and, if mqtt-message arrives, module sends MM Notifications based on the pre-configured mqtt-to-notification Dictionary rules.
- Listens to the MM Notifications within your MagicMirror environment. If Notification arrives, module sends MQTT message based on the preconfigured notification-to-mqtt Dictionary rules.
DOWNLOAD
Tom-Hirschberger/MMM-MQTTbridge
CONFIG STRUCTURE
For better understanding, we have divided config into 3 sections:
- General configurations in
config.js
; - “NOTIFICATION to MQTT” dictionary rules;
- “MQTT to NOTIFICATION” dictionary rules;
GENERAL SECTION
{
module: 'MMM-MQTTbridge',
disabled: false,
config: {
mqttServer: "mqtt://:@localhost:1883",
mqttConfig:
{
listenMqtt: true,
interval: 300000,
},
notiConfig:
{
listenNoti: true,
ignoreNotiId: ["CLOCK_MINUTE", "NEWS_FEED"],
ignoreNotiSender: ["SYSTEM", "NEWS_FEED"],
},
// set "NOTIFICATIONS -> MQTT" dictionary at /dict/notiDictionary.js
// set "MQTT -> NOTIFICATIONS" dictionary at /dict/mqttDictionary.js
},
},
GENERAL part
mqttServer
set you server address using the following format: “mqtt://”+USERNAME+“:”+PASSWORD+“@”+IPADDRESS+“:”+PORT. E.g. if you are using your broker without username/password on localhost with port 1883, you config should looks “mqtt://:@localhost:1883”.
MQTT part
listenMqtt
- turn on/off the listening of MQTT messages. Set tofalse
if you are going to use only NOTI->MQTT dictionary to save CPU usage;interval
- interval for MQTT status update, default is 300000ms.
(topics for subscription are taken from mqttDictionary.js
NOTIFICATION part
listenNoti
- turn on/off the listening of NOTIFICATIONS. Set tofalse
if you are going to use only MQTT->NOTI dictionary to save CPU usage;ignoreNotiId
- list your NOTIFICATION ID that should be ignored from processing, this saves CPU usage. E.g. [“CLOCK_MINUTE”, “NEWS_FEED”],ignoreNotiSender
- list your NOTIFICATION SENDERS that should be ignored from processing, this saves CPU usage. E.g. [“system”, “NEWS_FEED”]
NOTIFICATIONS to MQTT DICTIONARY SECTION
Should be set within ~/MagicMirror/modules/MMM-MQTTbridge/dict/notiDictionary.js
If payloadValue is empty, the actual payload of the notification will be used as MQTT payload.
If payloadValue is specified and matches the payload received via the notification, mqttMsgPayload will be used as MQTT payload.
var notiHook = [
{
notiId: "CLOCK_SECOND",
notiPayload: [
{
payloadValue: '10',
notiMqttCmd: ["Command 1"]
},
{
payloadValue: '20',
notiMqttCmd: ["Command 2"]
},
{
payloadValue: '30',
notiMqttCmd: ["Command 1"]
},
],
},
];
var notiMqttCommands = [
{
commandId: "Command 1",
mqttTopic: "myhome/kitchen/light/set",
mqttMsgPayload: '{"state":"OFF"}'
},
{
commandId: "Command 2",
mqttTopic: "myhome/kitchen/light/set",
mqttMsgPayload: '{"state":"ON"}'
},
];
MQTT to NOTIFICATIONS DICTIONARY SECTION
Should be set within ~/MagicMirror/modules/MMM-MQTTbridge/dict/mqttDictionary.js
If payloadValue is empty, the actual payload of the MQTT message will be used as notification payload.
If payloadValue is specified and matches the payload received via MQTT, notiPayload will be used as notification payload.
var mqttHook = [
{
mqttTopic: "dahoam/test",
mqttPayload: [
{
payloadValue: "ASSISTANT_LISTEN",
mqttNotiCmd: ["Command 1"]
},
{
payloadValue: "",
mqttNotiCmd: ["Command 2"]
},
],
},
{
mqttTopic: "dahoam/test2",
mqttPayload: [
{
payloadValue: "",
mqttNotiCmd: ["Command 2"]
},
],
},
];
var mqttNotiCommands = [
{
commandId: "Command 1",
notiID: "ASSISTANT_LISTEN",
notiPayload: 'BLABLABLA-1'
},
{
commandId: "Command 2",
notiID: "ASSISTANT_LISTEN",
notiPayload: ''
},
];
TESTED ENVIRONMENT
- Raspberry Pi 3 B+;
- Clean Updated Upgarded Raspbian Buster;
- MagicMirror ^2.10.1;
- mqtt-broker eclipse-mosquitto run in docker on the same RPi;
- mqtt-client on Windows10.