MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-MQTTbridge

    Scheduled Pinned Locked Moved Unsolved System
    44 Posts 14 Posters 20.6k Views 15 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F Offline
      fribse @Serge
      last edited by

      @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.

      1 Reply Last reply Reply Quote 0
      • SergeS Offline
        Serge
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • F Offline
          fribse
          last edited by fribse

          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)

          1 Reply Last reply Reply Quote 0
          • rudibaraniR Offline
            rudibarani Project Sponsor
            last edited by

            This looks very interesting! Thanks a lot for the effort to create this module. I look forward to trying it :)

            1 Reply Last reply Reply Quote 0
            • O Offline
              oberpiller
              last edited by

              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 of ARTICLE_INFO_RESPONSE. I took a look at the source code and it seems like ARTICLE_INFO_RESPONSE is kind of an Array. I spend hours trying to get the “URL” variable from this Array into mqttMsgPayload:. Is it possible to get variables (from “arrays”) into the mqttMsgPayload variable 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!!!

              SergeS 1 Reply Last reply Reply Quote 0
              • C Offline
                chimera
                last edited by

                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!

                1 Reply Last reply Reply Quote 0
                • SergeS Offline
                  Serge
                  last edited by

                  @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?

                  1 Reply Last reply Reply Quote 0
                  • SergeS Offline
                    Serge @oberpiller
                    last edited by Serge

                    @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.
                      },
                    ];
                    
                    
                    SergeS 1 Reply Last reply Reply Quote 0
                    • SergeS Offline
                      Serge @Serge
                      last edited by

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        shinebright
                        last edited by

                        When i publish 1 message, it’s receiving it multiple times for some reason. Do i need to be worried?
                        screenshot

                        SergeS 1 Reply Last reply Reply Quote 0
                        • SergeS Offline
                          Serge @shinebright
                          last edited by

                          @shinebright should produce one note per each mqtt message, check your settings once more or try to install on clean mm setup.

                          S 1 Reply Last reply Reply Quote 0
                          • S Offline
                            shinebright @Serge
                            last edited by

                            @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. :)

                            SergeS 1 Reply Last reply Reply Quote 1
                            • SergeS Offline
                              Serge @shinebright
                              last edited by

                              @shinebright what you had changed? Could you tell soi can add it as an option for the next releases

                              1 Reply Last reply Reply Quote 0
                              • F Offline
                                fribse
                                last edited by

                                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?

                                SergeS 1 Reply Last reply Reply Quote 0
                                • SergeS Offline
                                  Serge @fribse
                                  last edited by Serge

                                  This post is deleted!
                                  1 Reply Last reply Reply Quote 0
                                  • SergeS Offline
                                    Serge
                                    last edited by Serge

                                    Version 1.1 released https://github.com/sergge1/MMM-MQTTbridge

                                    Code updated with the help of community members.
                                    Now,

                                    • mqtt topics introduced into mqttDictionary. This allows now:
                                      – Subscribe to that specific topic from the mqttDictionary.
                                      – now you can specify different behavior for the same payload from different topics,
                                      e.g. if you got the mqttPayload “20” at “kitchen/temperature” topic and at “kitchen/humiduty” topic - different Command could be executed (before module recognized only payload for all the topics subscribed);

                                    • Now, if notiPayload or mqttPayload are not specified within mqttDictionary or notiDictionary, the respective payload from mqtt or noti will be sent as payload for noti or mqtt.
                                      E.g. if MM receives the mqtt message at “kitchen/temperature” with payload “20”, and mqttDictionary does not have specified payload at all - the “20” will go as payload for issued Noti.

                                    • All errors of several mqtt connections disappear;

                                    • mqttBridgeFormatOnly - not used anymore;

                                    • Changed mqttDictionary according to notiDictionary. Subscription to topic only once

                                    Please do not forget to change the config section and mqttDictionary accroding to the new structure.

                                    1 Reply Last reply Reply Quote 0
                                    • cowboysdudeC Offline
                                      cowboysdude Module Developer
                                      last edited by

                                      This is really needed and very nice!! Thank you!

                                      1 Reply Last reply Reply Quote 0
                                      • M Offline
                                        majdzik84
                                        last edited by

                                        Stupid novice question. How can I update the module? :) I have to remove the old one and upload the new one, is there any command to update the already uploaded module?

                                        S 1 Reply Last reply Reply Quote 0
                                        • S Offline
                                          sdetweil @majdzik84
                                          last edited by

                                          @majdzik84 upload? internet is upload, local computer is download

                                          to update a module locally, you go to that module folder and do a git pull

                                          sometimes you also need to do npm install again, but I would try first without it

                                          Sam

                                          How to add modules

                                          learning how to use browser developers window for css changes

                                          1 Reply Last reply Reply Quote 0
                                          • K Offline
                                            KSumwalt
                                            last edited by

                                            Hello,

                                            I installed the module on Aug 18, 2020 and have it connecting to my broker. Either I have something off or the module always sends out the notification’s payload and I cannot over-ride such. My notiDictionary.js file looks like this:

                                            
                                            var notiHook = [
                                              {
                                                notiId: "USERS_LOGIN",
                                                notiPayload: [
                                                  {
                                                    payloadValue: '', 
                                                    notiMqttCmd: ["Command 1"]
                                                  },
                                                ],
                                              },
                                              {
                                                notiId: "SHOW_ALERT",
                                                notiPayload: [
                                                  {
                                                    payloadValue: '', 
                                                    notiMqttCmd: ["Command 2"]
                                                  },
                                                ],
                                              },
                                              {
                                                notiId: "NEWS_FEED",
                                                notiPayload: [
                                                  {
                                                    payloadValue: '', 
                                                    notiMqttCmd: ["Command 3"]
                                                  },
                                                ],
                                              },
                                            ];
                                            var notiMqttCommands = [
                                              {
                                                commandId: "Command 1",
                                                mqttTopic: "mirror/profile",
                                                mqttMsgPayload: 'george'
                                             //    mqttMsgPayload: '{state:"OFF"}'
                                              },
                                              {
                                                commandId: "Command 2",
                                                mqttTopic: "mirror/alert/set",
                                                mqttMsgPayload: 'on'
                                              },
                                              {
                                                commandId: "Command 3",
                                                mqttTopic: "mirror/alert/test",
                                                mqttMsgPayload: 'go'
                                              },
                                            ];
                                            
                                            module.exports = { notiHook, notiMqttCommands };
                                            
                                            

                                            When an alert is shown, the SHOW_ALERT send an MQTT Topic of mirror/alert/set but the payload according to MQTT Snooper and my HomeSeer system is [object Object]. I expected it to be a string of on. NEWS_FEED does noth8ing, as expected from the config. USERS_LOGIN is from the MMM-Face-Reco-DNN module. It has a string value of the person who’s face it recognizes. When it recognizes me, the payload for the MQTT topic is Karl both when I have no value and when I have George in the payload setting as shown above.

                                            This is how I have the module configured in the config.js file:

                                            		{
                                            			module: 'MMM-MQTTbridge',
                                            //			disabled: false,
                                            			config: {
                                            				mqttServer: "mqtt://192.168.1.2: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
                                            			},
                                            		},
                                            
                                            

                                            What might I be doing wrong?

                                            Note that for an IP address and no username/password I had to set the server to mqttServer: “mqtt://192.168.1.2:1883”, dropping the colon (:) prior to the IP address. I had it in there based on the provided settings for the localhost version.

                                            SergeS 3 Replies Last reply Reply Quote 0

                                            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
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy