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 16.7k 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
      last edited by fribse

      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"}'
          },
        ];
      
      1 Reply Last reply Reply Quote 0
      • ? Offline
        A Former User
        last edited by

        @fribse said in MMM-MQTTbridge:
        notiPayload: '{action; "BRIGHTNESS", value: "100"}'

        attention the syntax is not correct

        try wih:

        notiPayload: '{action: "BRIGHTNESS", value: "100"}'

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

          @Bugsounet Thanks, it doesn’t change the behaviour though :-)

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

            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…

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

              @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: true or USER_PRESENCE: false is issued by the MMM-Remote-Control.
              So configure your noti dictionary with these lines and you will get mqtt as soon as the USER_PRESENCE: true\false arrive. 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 ignoreNotiSender a 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).

              F 1 Reply Last reply Reply Quote 0
              • 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
                        • 1
                        • 2
                        • 3
                        • 4
                        • 5
                        • 5 / 5
                        • 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