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] A module to publish and receive MQTT messages

    Scheduled Pinned Locked Moved Utilities
    16 Posts 3 Posters 4.9k Views 3 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.
    • Cr4z33C Offline
      Cr4z33
      last edited by

      @wishmaster270 I would like to intercept the MQTT event of when my Dahua video doorbell is pressed and send the stream to MMM-RTSPStream, but I don’t really know how to get the two modules to “talk” to each other… 😅

      So looking at DahuaVTO2MQTT registry this comes out when the doorbell button is pressed:

      MQTT message published, Topic: DahuaVTO/VideoTalkLog/Event, Payload: {"Action":"Pulse","Data":{"EndState":"Missed","LocalNumber":"9901","LocaleTime":"2024-07-22 10:09:27","RealUTC":1721635767,"TalkTime":0,"UTC":1721639367}}
      

      Now looking at MMM-RTSPStream readme this is the section where it explains how to control it from other modules (aka MMM-MQTTbridge), but as I said above it didn’t make sense to me.

      Can you please help me (at least on your module’s side)?

      wishmaster270W 1 Reply Last reply Reply Quote 0
      • wishmaster270W Offline
        wishmaster270 Module Developer @Cr4z33
        last edited by

        @Cr4z33 Hi, you will first need the URL of the RTSP stream of your camera.
        In the next step you will need to subscribe to the topic in the file mqttDictionary.js

        var mqttHook = [
            {
              mqttTopic: "DahuaVTO/VideoTalkLog/Event",
              mqttPayload: [
                {
                   jsonpath: "Action", 
                   conditions: [
                               {
                                 type: "eq",
                                 value: "Pulse"
                               },
                             ],
                  mqttNotiCmd: ["doorbell"]
                },
              ],
            },
          ];
        var mqttNotiCommands = [
            {
              commandId: "doorbell",
              notiID: "RTSP-PLAY",
              notiPayload: "YOUR-STREAM-URL" 
            },
          ]; 
        

        But you will need to find a way to stop the stream in any way.

        Cr4z33C 1 Reply Last reply Reply Quote 1
        • Cr4z33C Offline
          Cr4z33 @wishmaster270
          last edited by

          @wishmaster270 thank you mate!

          Yeah I will add a timeout command as I don’t think it will take much to search for it. 🙂

          Cr4z33C 1 Reply Last reply Reply Quote 0
          • Cr4z33C Offline
            Cr4z33 @Cr4z33
            last edited by

            @wishmaster270 sorry to bother you again.

            Right now my mqtt Dictionary.js looks like this

            var mqttHook = [
              {
                mqttTopic: "zigbee2mqtt/BTicino F20T60A",
                mqttPayload: [
                  {
                    payloadValue: "",
                    mqttNotiCmd: ["POWERMETER"],
                    mqttPayload: ""
                  },
                ],
              },
            ];
            
            var mqttNotiCommands = [
              {
                commandId: "POWERMETER",
                notiID: "POWERMETER_VALUES",
              },
            ];
            
            module.exports = { mqttHook,  mqttNotiCommands};
            

            so how should I add the new piece of code please?

            wishmaster270W 1 Reply Last reply Reply Quote 0
            • wishmaster270W Offline
              wishmaster270 Module Developer @Cr4z33
              last edited by

              @Cr4z33 The two datatstructures are arrays containing objects. So you can simply append the two objects…

              var mqttHook = [
                {
                  mqttTopic: "zigbee2mqtt/BTicino F20T60A",
                  mqttPayload: [
                    {
                      payloadValue: "",
                      mqttNotiCmd: ["POWERMETER"],
                      mqttPayload: ""
                    },
                  ],
                },
                {
                    mqttTopic: "DahuaVTO/VideoTalkLog/Event",
                    mqttPayload: [
                      {
                         jsonpath: "Action", 
                         conditions: [
                                     {
                                       type: "eq",
                                       value: "Pulse"
                                     },
                                   ],
                        mqttNotiCmd: ["doorbell"]
                      },
                    ],
                  },
              ];
              
              var mqttNotiCommands = [
                {
                  commandId: "POWERMETER",
                  notiID: "POWERMETER_VALUES",
                },
                {
                    commandId: "doorbell",
                    notiID: "RTSP-PLAY",
                    notiPayload: "YOUR-STREAM-URL" 
                  },
              ];
              
              module.exports = { mqttHook,  mqttNotiCommands};
              
              
              Cr4z33C 1 Reply Last reply Reply Quote 1
              • Cr4z33C Offline
                Cr4z33 @wishmaster270
                last edited by Cr4z33

                @wishmaster270 thank you again!

                However nothing happens in the MagicMirror frontend (although I can see the MQTT event if running MM by npm start

                [23.07.2024 17:15.55.132] [LOG]   [MQTT bridge] MQTT message received. Topic: DahuaVTO/VideoTalkLog/Event, message: {"Action":"Pulse","Data":{"EndState":"Missed","LocalNumber":"9901","LocaleTime":"2024-07-23 17:15:55","RealUTC":1721747755,"TalkTime":0,"UTC":1721751355}}
                

                I suspect that I am entering the wrong data at

                "YOUR-STREAM-URL"
                

                What shall I enter? Just the IP address or something like ie.

                rtsp://username:password@IPADDRESS/cam/realmonitor?channel=1&subtype=1#backchannel=0
                
                S wishmaster270W 2 Replies Last reply Reply Quote 0
                • S Offline
                  sdetweil @Cr4z33
                  last edited by

                  @Cr4z33 said in [MMM-MQTTbridge] A module to publish and receive MQTT messages:

                  although I can see the MQTT event if running MM by npm start

                  if using pm2 to autolaunch MM, then

                  pm2 logs --lines=xxxx
                  

                  will show you the last xxxx of the output

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  Cr4z33C 1 Reply Last reply Reply Quote 1
                  • wishmaster270W Offline
                    wishmaster270 Module Developer @Cr4z33
                    last edited by

                    @Cr4z33 Hi,

                    think I found the problem.
                    You need to send streamX as value where X is the number of the stream in the configuration of MMM-RTSPStream.
                    You will need to configure the camera information in the MMM-RTSPStream module and only will be able to start the stream by notification

                    Cr4z33C 1 Reply Last reply Reply Quote 1
                    • Cr4z33C Offline
                      Cr4z33 @sdetweil
                      last edited by Cr4z33

                      @sdetweil said in [MMM-MQTTbridge] A module to publish and receive MQTT messages:

                      @Cr4z33 said in [MMM-MQTTbridge] A module to publish and receive MQTT messages:

                      although I can see the MQTT event if running MM by npm start

                      if using pm2 to autolaunch MM, then

                      pm2 logs --lines=xxxx
                      

                      will show you the last xxxx of the output

                      @wishmaster270 said in [MMM-MQTTbridge] A module to publish and receive MQTT messages:

                      @Cr4z33 Hi,

                      think I found the problem.
                      You need to send streamX as value where X is the number of the stream in the configuration of MMM-RTSPStream.
                      You will need to configure the camera information in the MMM-RTSPStream module and only will be able to start the stream by notification

                      Thank you both will do as soon as I am back at home again!

                      1 Reply Last reply Reply Quote 0
                      • Cr4z33C Offline
                        Cr4z33 @wishmaster270
                        last edited by

                        @wishmaster270 said in [MMM-MQTTbridge] A module to publish and receive MQTT messages:

                        @Cr4z33 Hi,

                        think I found the problem.
                        You need to send streamX as value where X is the number of the stream in the configuration of MMM-RTSPStream.
                        You will need to configure the camera information in the MMM-RTSPStream module and only will be able to start the stream by notification

                        Hi mate I am coming back after a long time because real life was very busy lately and I could get back at this only in the last 2 days.

                        So based on your reply I set mqttDictionary.js like this

                        var mqttHook = [
                          {
                            mqttTopic: "zigbee2mqtt/BTicino F20T60A",
                            mqttPayload: [
                              {
                                payloadValue: "",
                                mqttNotiCmd: ["POWERMETER"],
                                mqttPayload: ""
                              },
                            ],
                          },
                          {
                              mqttTopic: "DahuaVTO/VideoTalkLog/Event",
                              mqttPayload: [
                                {
                                   jsonpath: "Action", 
                                   conditions: [
                                               {
                                                 type: "eq",
                                                 value: "Pulse"
                                               },
                                             ],
                                  mqttNotiCmd: ["videocitofono"]
                                },
                              ],
                            },
                        ];
                        
                        var mqttNotiCommands = [
                          {
                            commandId: "POWERMETER",
                            notiID: "POWERMETER_VALUES",
                          },
                          {
                              commandId: "videocitofono",
                              notiID: "RTSP-PLAY",
                              notiPayload: "stream1" 
                            },
                        ];
                        
                        module.exports = { mqttHook,  mqttNotiCommands};
                        

                        Although stream1 is the one and only stream used in MMM-RTSPStream I still get no playback when the doorbell button is pressed, but if I start the stream by clicking on the module’s playback button then it works.

                        I paste here also the PM2 log line (note that sensitive data have been censored) when the doorbell button is pressed:

                        [23.09.2024 12:36.03.216] [LOG]   [MQTT bridge] MQTT message received. Topic: DahuaVTO/VideoTalkLog/Event, message: {
                            "Action": "Pulse",
                            "Code": "VideoTalkLog",
                            "Data": {
                                "EndState": "Missed",
                                "LocalNumber": "9901",
                                "LocaleTime": "2024-09-23 12:36:03",
                                "RealUTC": 1727087763,
                                "TalkTime": 0,
                                "UTC": 1727091363.0
                            },
                            "Index": 0,
                            "deviceType": "DHI-VTO2202F-P-S2",
                            "serialNumber": "*******"
                        }
                        

                        Can you please see why it’s not working yet? 🙏🏼

                        wishmaster270W 1 Reply Last reply Reply Quote 0
                        • wishmaster270W Offline
                          wishmaster270 Module Developer @Cr4z33
                          last edited by

                          @Cr4z33 Hi and welcome back.
                          I still do not have a glue about the RTSP module.

                          Can you please provide your RTSP config. I try to reproduce the problem but do not have much time to test at the moment.

                          Cr4z33C 1 Reply Last reply Reply Quote 1
                          • Cr4z33C Offline
                            Cr4z33 @wishmaster270
                            last edited by

                            @wishmaster270 here is the code of my RTSPStream module thanks. 🙂

                            I replaced my video doorbell RTSP stream with some testing live HTTPS camera one as I couldn’t find a working RTSP testing stream.

                            Take your time as long as it takes. 👍🏼

                            {
                            			module: "MMM-RTSPStream",
                            			position: "middle_center",
                            			disabled: false,
                            			config: {
                            				autoStart: false,
                            				rotateStreams: true,
                            				rotateStreamTimeout: 10,
                            				moduleWidth: 500,
                            				moduleHeight: 281,
                            				localPlayer: 'vlc',
                            				moduleOffset: { left: -170, top: -125 },
                            				remotePlayer: 'ffmpeg',
                            				showSnapWhenPaused: false,
                            				remoteSnaps: false,
                            				shutdownDelay: 12,
                            				stream1: {
                            						name: 'Videocitofono',
                            						url: 'https://99663300.hopto.org:19526/Jpeg/1?authToken=7f9c4ca8-e776-40c9-b242-6882b7b4775e&1727250645145',
                            						frameRate: 'undefined',
                            						width: 500,
                            						height: 281,
                            						muted: true,
                            						ffmpegPort: 9999,
                            						},
                            				}
                            		},
                            
                            1 Reply Last reply Reply Quote -1
                            • Cr4z33C Offline
                              Cr4z33
                              last edited by

                              @wishmaster270 after I left this project abandoned for almost 1 year I went back to it, but I still can’t get it to work. 🥲

                              To resume what I want to achieve is to have MMM-RTSPStream popping up a live doorbell video feed on my smart mirror whenever someone presses the button.

                              The interested MQTT line is

                              2025-04-16 10:30:07,536 INFO __main__ Publishing MQTT message DahuaVTO/Invite/Event: {'Action': 'Pulse', 'Code': 'Invite', 'Data': {'CallID': '2', 'IsEncryptedStream': False, 'LocaleTime': '2025-04-16 10:30:07', 'LockNum': 2, 'RealUTC': 1744792207, 'SupportPaas': False, 'TCPPort': 37777, 'UTC': 1744795807.0, 'UserID': '101'}, 'Index': 0, 'deviceType': 'DHI-VTO3311Q-WP', 'serialNumber': '********'}
                              

                              I therefore edited my current mqttDictionary.js by adding

                              var mqttHook = [
                                {
                                  mqttTopic: "zigbee2mqtt/BTicino F20T60A",
                                  mqttPayload: [
                                    {
                                      payloadValue: "",
                                      mqttNotiCmd: ["POWERMETER"],
                                      mqttPayload: ""
                                    },
                                  ],
                                },
                                {
                                    mqttTopic: "DahuaVTO/Invite/Event",
                                    mqttPayload: [
                                      {
                                         jsonpath: "Action", 
                                         conditions: [
                                                     {
                                                       type: "eq",
                                                       value: "Pulse"
                                                     },
                                                   ],
                                        mqttNotiCmd: ["videocitofono"]
                                      },
                                    ],
                                  },
                              ];
                              
                              var mqttNotiCommands = [
                                {
                                  commandId: "POWERMETER",
                                  notiID: "POWERMETER_VALUES",
                                },
                                {
                                    commandId: "videocitofono",
                                    notiID: "RTSP-PLAY",
                                    notiPayload: "stream1" 
                                  },
                              ];
                              
                              module.exports = { mqttHook,  mqttNotiCommands};
                              

                              I then edited in config.js the lines related to the MMM-RTSPStream module like this

                              {
                              			module: "MMM-RTSPStream",
                              			position: "middle_center",
                              			disabled: false,
                              			config: {
                              				autoStart: false,
                              				rotateStreams: true,
                              				rotateStreamTimeout: 10,
                              				moduleWidth: 500,
                              				moduleHeight: 281,
                              				localPlayer: 'vlc',
                              				moduleOffset: { left: -170, top: -125 },
                              				remotePlayer: 'ffmpeg',
                              				showSnapWhenPaused: false,
                              				remoteSnaps: false,
                              				shutdownDelay: 12,
                              				stream1: {
                              						name: 'Videocitofono',
                              						url: 'rtsp://username:password@ipaddress/cam/realmonitor?channel=1&subtype=1#backchannel=0',
                              						frameRate: 'undefined',
                              						width: 500,
                              						height: 281,
                              						muted: true,
                              						ffmpegPort: 9999,
                              						},
                              				}
                              		},
                              

                              Nothing happens when I press the doorbell button.

                              Maybe we need to add some more data to mqttDictionary.js?

                              wishmaster270W 1 Reply Last reply Reply Quote 0
                              • wishmaster270W Offline
                                wishmaster270 Module Developer @Cr4z33
                                last edited by

                                @Cr4z33 Sorry, but I am very busy at the moment.
                                Did you find any response of the MQTT module in your logs of MagicMirror if you enable the debug option of it?

                                Cr4z33C 1 Reply Last reply Reply Quote 0
                                • Cr4z33C Offline
                                  Cr4z33 @wishmaster270
                                  last edited by

                                  @wishmaster270 hi and sorry for bothering you hehe.

                                  No there’s actually no sign of doorbell button pressing looking at the logs.

                                  All I can see is my BTicino power meter and that’s it…

                                  PM2 Log

                                  1 Reply 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 / 1
                                  • 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