Read the statement by Michael Teeuw here.
MMM-MQTTbridge
-
@fribse said in MMM-MQTTbridge:
[16:04:30.547] [LOG] [MQTT bridge] MQTT message received. Topic: cmnd/home/bathroom/mirror, message: TURN_OFF_SCREEN
the log record above means that MMM-MQTTbridge received mqtt message at the topic
cmnd/home/bathroom/mirrorwith payloadTURN_OFF_SCREEN.The next log record
[16:04:30.639] [LOG] [MQTT bridge] MQTT -> NOTI issued: REMOTE_ACTION, payload: {action: ‘MONITOROFF’}
says that MQTTbridge issued MagicMirror’s notification
REMOTE_ACTIONwith payload{action: 'MONITOROFF'}which is exactly what you need. So this part works well.However, the further messages in log
[16:04:30.646] [LOG] Whoops! There was an uncaught exception…
[16:04:30.665] [LOG] MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
[16:04:30.667] [LOG] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issuessays that something went wrong with the MM core. That could be the reason for not executing the command by another module.
To find out the reason, you need to localize the error. Try to disable all modules and then add modules one-by-one and find which one cause that error.
hint: to disable modules, usedisabled: truewithin each module config.Change also
listenNoti:tofalse,in MQTTbridge config if you do not need to convert Noti to Mqtt messages. So the module will not check all incoming MM’s notifications.Here is the full log within my setup, I just sent a simple message to issue noti
TESTwith payloadmessage:pi@raspberrypi:~/MagicMirror $ npm start dev > magicmirror@2.10.1 start /home/pi/MagicMirror > ./run-start.sh "dev" [23:48:05.361] [LOG] Starting MagicMirror: v2.10.1 [23:48:05.395] [LOG] Loading config ... [23:48:05.435] [LOG] Loading module helpers ... [23:48:05.444] [LOG] No helper found for module: clock. [23:48:07.792] [LOG] Initializing new module helper ... [23:48:07.794] [LOG] Module helper loaded: calendar [23:48:07.800] [LOG] No helper found for module: currentweather. [23:48:07.802] [LOG] No helper found for module: weatherforecast. [23:48:07.890] [LOG] Initializing new module helper ... [23:48:07.891] [LOG] Module helper loaded: newsfeed [23:48:08.506] [LOG] Initializing new module helper ... [23:48:08.507] [LOG] Module helper loaded: MMM-MQTTbridge [23:48:08.691] [LOG] All module helpers loaded. [23:48:08.693] [LOG] Starting server on port 8181 ... [23:48:08.705] [INFO] You're using a full whitelist configuration to allow for all IPs [23:48:08.735] [LOG] Server started ... [23:48:08.740] [LOG] Connecting socket for: calendar [23:48:08.744] [LOG] Starting node helper for: calendar [23:48:08.747] [LOG] Connecting socket for: newsfeed [23:48:08.749] [LOG] Starting module: newsfeed [23:48:08.752] [LOG] Connecting socket for: MMM-MQTTbridge [23:48:08.754] [LOG] [MQTT bridge] Module started [23:48:08.800] [LOG] Sockets connected & modules started ... [23:48:09.890] [LOG] Launching application. [23:48:26.071] [LOG] [MQTT bridge] Subscribed to the topic: home/smartmirror/bathroom/light/set [23:51:43.274] [LOG] [MQTT bridge] MQTT message received. Topic: home/smartmirror/bathroom/light/set, message: TEST:message [23:51:43.420] [LOG] [MQTT bridge] MQTT -> NOTI issued: TEST, payload: message -
Hmm, not really sure what changed. I’ve tried setting the notilisten to false, and then I don’t see the error, but after reactivating it, I still dont’ see it.
I can see that the log reports state 0x6 when the monitor is on, and 0x2 when it’s off.
I can send commands to the Remote_Control module via http api, but nothing happens when I try it via the mqttbridge.
I guess I have to ask @Jopyth about that?I also tried changing the quotation markings in the dict file, to match the Remote_Control parameters in the examples, but no change :-(
var mqttNotiCommands = [ { commandId: "MONITOROFF", notiID: 'REMOTE_ACTION', notiPayload: '{action: "MONITOROFF"}' }, { commandId: "MONITORON", notiID: 'REMOTE_ACTION', notiPayload: '{action: "MONITORON"}' }, { commandId: "UNDIM", notiID: 'REMOTE_ACTION', notiPayload: '{action; "BRIGHTNESS", value: "100"}' }, { commandId: "DIM", notiID: "REMOTE_ACTION", notiPayload: '{action: "BRIGHTNESS", value: "75"}' }, { commandId: "RESTART", notiID: "REMOTE_ACTION", notiPayload: '{action: "RESTART"}' }, ]; -
@fribse said in MMM-MQTTbridge:
notiPayload: '{action; "BRIGHTNESS", value: "100"}'attention the syntax is not correct
try wih:
notiPayload: '{action: "BRIGHTNESS", value: "100"}' -
@Bugsounet Thanks, it doesn’t change the behaviour though :-)
-
Darned, I just found the problem.
I had this in the mqttdictionary:
var mqttHook = [ { mqttPayload: "TURN_OFF_SCREEN", mqttNotiCmd: ["MONITOROFF"] },But I was sending a MQTT message with ‘MONITOROFF’, if I send ‘TURN_OFF_SCREEN’ it works perfectly :-)
Thankyou @Serge and @Bugsounet for this GREAT module, just the missing piece.
Now I have to figure out about the noti->mqtt thing, I can see that the monitor status is reported in the log, but I can’t see what ‘notification’ is sent…P.S. the logfile looks a bit weird:
0|mm | [MQTT bridge] MQTT message received. Topic: cmnd/bathroom/mirror, message: MONITORON 0|mm | [MQTT bridge] MQTT -> NOTI issued: REMOTE_ACTION, payload: **[object Object]**But it works…
-
@fribse , finally it works for you. So the reason was the incorrect config initially as I understood.
P.S. the logfile looks a bit weird:
log means that the payload of the noti is an “object” and not other type of data.
Now I have to figure out about the noti->mqtt thing,
Exactly the same as for mqtt->noti: create an noti->mqtt dictionary and that is, literally, all.
I can see that the monitor status is reported in the log, but I can’t see what ‘notification’ is sent
here author https://github.com/Jopyth/MMM-Remote-Control#system-control wrote that Noti
USER_PRESENCE: trueorUSER_PRESENCE: falseis issued by the MMM-Remote-Control.
So configure your noti dictionary with these lines and you will get mqtt as soon as theUSER_PRESENCE: true\falsearrive. Pay attention, that the same noti could by issued by other modules, e.g.Also, you can control other modules via mqtt-noti command. Starting from hiding/showing and ending with direct control. Examples:
Within your smarthome ecosystem based on MQTT/HomeAssistant (HA) - a great modules are- MMM-NewPIR - use your PIR sensor, integrated into MM as an instance within HA ecosystem and add it states to the scenes automation.
- MMM-Youtube, - send mqtt->noti to this module and control via HA scenes e.g. turn-on news on Youtube in the morning etc.
- MMM-Volume, set and turn-on/off the volume (e.g. during the day/night time)
- Google Assistant etc.
Also, just a hint: add to
ignoreNotiSendera default “clock” module. I will add this by default to the next release. The reason: “clock” module sends notification every second. So adding “clock” to ignored list will prevent MQTTbridge from checking “clock’s” notification in dictionary every second (just to save rpi cpu usage). -
@Serge Yes, I did most of this already, I used the MMM-ViewNotifications to monitor which notifications was sent, and added all those I am not interested in :-)
Thankyou for the followup. -
here is fribse’s great tutorial for simple integration of MM into Home Assistant ecosystem.
Following the logic from his post, user can expand it and control everything on its MM:https://community.home-assistant.io/t/magicmirror-integration-into-home-assistant-with-mqtt/177246
-
Hi @Serge , I found one thing missing from the noti->mqtt, the QOS is not settable.
I can see that you send them with qos:0, it should be settable to 0,1 or 2 as to how much guarantee for delivery it’s supposed to get.
Other than that, it’s working perfectly, even via Google Home to turn the screen on and off (via the switch in Home Assistant) -
This looks very interesting! Thanks a lot for the effort to create this module. I look forward to trying it :)
-
Hey @Serge
i am struggeling around with publishing a variable. Here is the thing: I want to publish a variable from the default “newsfeed” module of MMM. I already get a notification ofARTICLE_INFO_RESPONSE. I took a look at the source code and it seems likeARTICLE_INFO_RESPONSEis kind of an Array. I spend hours trying to get the “URL” variable from this Array intomqttMsgPayload:. Is it possible to get variables (from “arrays”) into themqttMsgPayloadvariable of NotiDictionary.js?
It can be a really easy thing, but I am kind of a newbie in JavaScrip…But newertheless I really like your module! Very good job!!!
-
This is perfect!!! Thanks so much! I run OpenHAB and utilise MQTT quite heavily. However I don’t like MQTT persistence, as it doesn’t work for me in OpenHAB. I run MMM-MQTT module in MM, but the problem with that is, when MagicMirror starts up it doesn’t display MQTT topic payload, as many MQTT updates I get are on intermittent basis (eg: swimming pool temperature, only updates if it changes, garden sprinkler last run, only updates when it’s run etc) So I’ve used this with MMM-Pages (I have several MM screens) and the 2nd page has mostly OpenHAB related info that I want to display. So I use the Notification ‘PAGE_CHANGED’ with payload = 1 (as pages start from 0) to publish an MQTT message of openhab/magicmirror/requestmqtt = ON. This is tied to a switch item in OpenHAB, and a rule in OpenHAB detects when the switch gets turned on, and in turn publishes a list of latest home automation data out to MQTT, which gets picked up and displayed on Magic Mirror. Prior to this, I would have a lot of items with “updating…” and had to wait until the device sent its latest information to MQTT.
This covers all bases and more. I can see this becoming a very powerful little module!
Thanks again!
-
@chimera said in MMM-MQTTbridge:
eg: swimming pool temperature, only updates if it changes, garden sprinkler last run, only updates when it’s run, etc
As far as I understood you, you need to issue some NOTI during the MM/Module startup, right?
How would be the best option to do that? One possible solution is to have a file with the list of topics (e.g. “swimmingpool/temp/status”, “gardenspirnkler/run/status”) to which MQTTbrdige will send the mqtt-messages at startup.
Will this solve your problem with the integration of MM to your smart home? -
@oberpiller said in MMM-MQTTbridge:
Is it possible to get variables (from “arrays”) into the mqttMsgPayload variable of NotiDictionary.js?
nope. I will think about it.
should it work somehow like that:
In notiMqtt dict should be specified whether we are using variable or not and, if yes, use it:var notiMqttCommands = [ { commandId: "Command 1", mqttTopic: "myhome/kitchen/light/set", useVariables: true, //added new setting to the dict to mqttMsgPayload: ARTICLE_INFO_RESPONSE //if useVriables=true, put here the variable name. If useVariable=false or not stated - mqttMsgPayload will send "ARTICLE_INFO_RESPONSE" in its payload. }, ]; -
This post is deleted! -
When i publish 1 message, it’s receiving it multiple times for some reason. Do i need to be worried?
-
@shinebright should produce one note per each mqtt message, check your settings once more or try to install on clean mm setup.
-
@Serge got it thanks! i’ll give that a try. awesome module by the way, i managed to change some of your codes along with the compliments module. Now I’m sending messages from my phone to update the mirror compliments and the kids think the mirror is replying back to them. :)
-
@shinebright what you had changed? Could you tell soi can add it as an option for the next releases
-
Hi @Serge
I’ve finally received the mirror itself, so now the MagicMirror is finally getting finished.
One of the things was to update the MM itself, as well as a few modules (screencast).
After doing that, I don’t see any mqtt status messages going out, and it doesn’t react on incoming either.
I’ve checked the username/password, still correct, and the IP hasn’t changed either?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login