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.

    Receive a HTTP request and subsequently wake up display and display alert/notification

    Scheduled Pinned Locked Moved Solved Troubleshooting
    14 Posts 3 Posters 1.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.
    • M Offline
      MilkShake
      last edited by

      Hi,
      I have been trying to display a notification on my MM upon the receival of a HTTP request that comes from my gate. When womeone pushes the button at the gate, the gate is able to do a HTTP request.

      It is setup to request: http://MYMM:8090/webhook

      When that is fired I receive a 200:OK.

      In my config I have:

      {
            module: "MMM-NotificationTrigger",
            config: {
              useWebhook:true,
              triggers:[
                {
                  trigger: "SHOW_ALERT",
                  fires: [
                    {
                      fire:"SHOW_ALERT",
                      payload:{
                              "title": "PORTEN",
                              "message": "Der er nogen ved porten",
                              "timer":5000
                              },
                    },
                  ],
                },
              ]
            }
       },
      

      Can anyone point me in the right direction?

      Much appreciated :)

      Br,
      Lars

      M 2 Replies Last reply Reply Quote 0
      • M Offline
        MilkShake @MMRIZE
        last edited by

        @MMRIZE said in Receive a HTTP request and subsequently wake up display and display alert/notification:

        @MilkShake said in Receive a HTTP request and subsequently wake up display and display alert/notification:

        It works when I include the notification in the URL like this:

        http://MMIP:8090/remote?action=NOTIFICATION&notification=SOMEONE_AT_THE_DOOR

        Simply, you can use this.

        http://MMIP:8090/webhook?notification=SOMEONE_AT_THE_DOOR
        

        That is the GET method.

        for the shellscript, your trial seems right, but you should take care for the path and the permission.
        I think this would be right. (It depends on your environment)

        exec: "bash /home/Kragh/monitor_on.sh",
        // OR
        exec: ". /home/Kragh/monitor_on.sh",
        

        Well, I got it working, sort off.

        I cannot get http://192.168.1.100:8090/webhook?action=notification=SOMEONE_AT_THE_DOOR to work. It returns a 200:OK but nothing is displayed.

        I have to use http://MMIP:8090/remote?action=NOTIFICATION&notification=SOMEONE_AT_THE_DOOR for it to work.

        M 1 Reply Last reply Reply Quote 0
        • M Offline
          MMRIZE @MilkShake
          last edited by

          @MilkShake
          What is the request body from the gate? “SHOW_ALERT”? I think it would be better to emit other dedicated custom notification other than “SHOW_ALERT”.

          S M 2 Replies Last reply Reply Quote 0
          • S Offline
            sdetweil @MMRIZE
            last edited by

            @MMRIZE he is trying to get the alert module popup

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • M Offline
              MilkShake @MMRIZE
              last edited by

              @MMRIZE said in Receive a HTTP request and subsequently wake up display and display alert/notification:

              @MilkShake
              What is the request body from the gate? “SHOW_ALERT”? I think it would be better to emit other dedicated custom notification other than “SHOW_ALERT”.

              It is just a webhook that is meant to get cached by MMM-NotificationTrigger module, that in turn should be able to send notifications to the Alert module.

              1 Reply Last reply Reply Quote 0
              • M Offline
                MMRIZE @MilkShake
                last edited by

                @MilkShake
                24fb8089-36b9-4131-96bf-5f1e7ad12574-image.png

                First, What request method and body is emitted from the gate?
                It should be something like;

                • endpoint : http://MYMM:8090/webhook
                • requestMethod : "POST"
                • requestHeader: "Content-type: application/json"
                • requestBody : (
                {
                  notification: "SOMEONE_AT_THE_DOOR"
                }
                

                If you select “GET” as requestMethod, you may need to deliver the notification as parameter instead of requestBody JSON

                Then you can configure like this.

                {
                	module: "MMM-NotificationTrigger",
                	config: {
                		useWebhook: true,
                		triggers: [
                			{
                				trigger: "SOMEONE_AT_THE_DOOR",
                				fires: [
                					{
                						fire: "SHOW_ALERT",
                						payload: {
                							title: "Someone arrives home",
                							message: "Welcome back home!",
                							timer: "10000",
                						}
                					}
                				]
                			}
                		]
                	}
                },
                
                M 2 Replies Last reply Reply Quote 0
                • M Offline
                  MilkShake @MMRIZE
                  last edited by

                  @MMRIZE said in Receive a HTTP request and subsequently wake up display and display alert/notification:

                  @MilkShake
                  24fb8089-36b9-4131-96bf-5f1e7ad12574-image.png

                  First, What request method and body is emitted from the gate?
                  It should be something like;

                  • endpoint : http://MYMM:8090/webhook
                  • requestMethod : "POST"
                  • requestHeader: "Content-type: application/json"
                  • requestBody : (
                  {
                    notification: "SOMEONE_AT_THE_DOOR"
                  }
                  

                  If you select “GET” as requestMethod, you may need to deliver the notification as parameter instead of requestBody JSON

                  Then you can configure like this.

                  {
                  	module: "MMM-NotificationTrigger",
                  	config: {
                  		useWebhook: true,
                  		triggers: [
                  			{
                  				trigger: "SOMEONE_AT_THE_DOOR",
                  				fires: [
                  					{
                  						fire: "SHOW_ALERT",
                  						payload: {
                  							title: "Someone arrives home",
                  							message: "Welcome back home!",
                  							timer: "10000",
                  						}
                  					}
                  				]
                  			}
                  		]
                  	}
                  },
                  

                  Thanks man! I will try that out. I think the doorbird appliance is using application/json POST requests, even though that is hard to find in the documentation.

                  M 1 Reply Last reply Reply Quote 0
                  • M Offline
                    MMRIZE @MilkShake
                    last edited by

                    @MilkShake
                    Could you share the doc? Let’s look inside together.

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      MilkShake @MMRIZE
                      last edited by

                      @MMRIZE All I have is this:

                      https://www.doorbird.com/downloads/manual_d10x_en_de.pdf

                      It works when I include the notification in the URL like this:

                      http://MMIP:8090/remote?action=NOTIFICATION&notification=SOMEONE_AT_THE_DOOR

                      That is sweet. Now I need to exec a shell script also.

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

                        Also, do you know the syntax for executing a shell script in MMM-NotificationTrigger?

                        I though it would be like this:

                        {
                                module: "MMM-NotificationTrigger",
                                config: {
                                        useWebhook: true,
                                        triggers: [
                                                {
                                                        trigger: "SOMEONE_AT_THE_DOOR",
                                                        fires: [
                                                                {
                                                                        fire: "SHOW_ALERT",
                                                                        exec: "home/Kragh/monitor_on.sh",
                                                                        payload: {
                                                                                title: "PORTEN",
                                                                                message: "Der er nogen ved porten!",
                                                                                timer: "10000",
                                                                        }
                                                                }
                                                        ]
                                                }
                                        ]
                                }
                        }
                        
                        

                        monitor_on.sh is set as executionable.

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          MMRIZE @MilkShake
                          last edited by MMRIZE

                          @MilkShake said in Receive a HTTP request and subsequently wake up display and display alert/notification:

                          It works when I include the notification in the URL like this:

                          http://MMIP:8090/remote?action=NOTIFICATION&notification=SOMEONE_AT_THE_DOOR

                          Simply, you can use this.

                          http://MMIP:8090/webhook?notification=SOMEONE_AT_THE_DOOR
                          

                          That is the GET method.

                          for the shellscript, your trial seems right, but you should take care for the path and the permission.
                          I think this would be right. (It depends on your environment)

                          exec: "bash /home/Kragh/monitor_on.sh",
                          // OR
                          exec: ". /home/Kragh/monitor_on.sh",
                          
                          M 1 Reply Last reply Reply Quote 0
                          • 1
                          • 2
                          • 1 / 2
                          • 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