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.

    JSON request module

    Scheduled Pinned Locked Moved Solved Requests
    41 Posts 3 Posters 11.0k Views 4 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.
    • E Offline
      ELMAGO
      last edited by

      hello,
      I am looking for a module that would display several JSON replies.
      I tested MMM-JSON but does not work black screen, MMM-JsonTable
      but is not multi url, MMM-json-feed the same.

      My urls are coordinated as follows:
      http://192.168.100.244:3000/ROOMTIME
      And the answer is
      // 20221123185334
      // http://192.168.100.244:3000/ROOMTIME

      {
      “status”: “successful”,
      “url”: “/ROOMTIME”,
      “method”: “GET”,
      “data”: 21.4
      }

      I will therefore need a module where I can display a specific name for each url, ex:
      Temp. Room 21.4°c

      Thank you in advance for your help.
      And sorry for my English.:face_savoring_food: :face_savoring_food:

      S wishmaster270W 2 Replies Last reply Reply Quote 0
      • E Offline
        ELMAGO @wishmaster270
        last edited by

        @wishmaster270

        Re Goodnight

        It’s awesome, it’s exactly what I wanted.

        Thank you so much.

        b3cb1a61-c845-4689-91a3-53944fca4ee8-image.png

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

          @ELMAGO I am not aware of any module that does interconnection between fetched tables.

          black screen, see the black screen item pinned at top of troubleshooting section

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          E 1 Reply Last reply Reply Quote 0
          • E Offline
            ELMAGO @sdetweil
            last edited by

            @sdetweil thank.

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

              @ELMAGO Hi,

              You can use a simple curl command to fetch the data and get the data send as notification with my MMM-CommandToNotification module. The module supports to call commands periodically.
              As you do have the data as payload of a notification then you can use my MMM-ValuesByNotification module to display it. This module is very powerful, allows parsing the payload as Json, selecting values in the Json with JSONPath syntax and even reformatting.

              E 1 Reply Last reply Reply Quote 0
              • E Offline
                ELMAGO @wishmaster270
                last edited by

                @wishmaster270

                Thank you for your reply.
                So I installed the two modules and configured my config as follows:

                //TEMPERATURE MAISON
                
                {
                   module: "MMM-CommandToNotification",
                   disabled: false,
                   config: {
                    updateInterval: 10,
                    commands: [
                     {
                      script: "http://192.168.100.244:3000/TEMPSALLE",
                      args: "-10 10",
                      timeout: 5,
                      notifications: [
                       "TEMPSALLE",
                       ],
                     },
                     ]
                   },
                  },
                
                
                // AFFICHAGE
                
                {
                   module: "MMM-ValuesByNotification",
                   position: "top_right",
                   header: "Module-1",
                   config: {
                    groups: [
                     {
                      items: [
                       {
                        notification: "TEMPSALLE",
                        itemTitle: "Item-1",
                        values: [
                         {
                          valueTitle: "Value-1",
                		valueUnit: "°C",
                		jsonpath: "data",
                         },
                        ]
                       },
                      ]
                     },
                    ]
                   },
                  },
                
                

                and i get :

                663f9695-cd87-4675-9191-428defbea809-image.png

                Can you help me ?

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

                  @ELMAGO You can NOT enter the url directly into the Command module. You need to call a valid Shell Command.
                  In your case I will suggest curl.

                  The full command will be:

                  curl -vs  http://192.168.100.244:3000/TEMPSALLE2
                  

                  So the command configuration should be something like:

                  {
                     module: "MMM-CommandToNotification",
                     disabled: false,
                     config: {
                      updateInterval: 10,
                      commands: [
                       {
                        script: "/usr/bin/curl",
                        args: "-vs  http://192.168.100.244:3000/TEMPSALLE2",
                        timeout: 5,
                        notifications: [
                         "TEMPSALLE",
                         ],
                       },
                       ]
                     },
                    },
                  

                  As a result the output of the curl command will be send as notification “TEMPSALE”.

                  You can test the curl command in a terminal.

                  E 1 Reply Last reply Reply Quote 0
                  • E Offline
                    ELMAGO @wishmaster270
                    last edited by

                    @wishmaster270 said in JSON request module:
                    Good evening

                    (I am in France)

                    Thanks for your answer but I still have the same result.

                    //TEMPERATURE MAISON
                    
                    {
                       module: "MMM-CommandToNotification",
                       disabled: false,
                       config: {
                        updateInterval: 10,
                        commands: [
                         {
                          script: "/usr/bin/curl",
                          args: "-vs  http://192.168.100.244:3000/TEMPSALLE",
                          timeout: 5,
                          notifications: [
                           "TEMPSALLE",
                           ],
                         },
                         ]
                       },
                      },
                    
                    
                    // AFFICHAGE
                    
                    {
                       module: "MMM-ValuesByNotification",
                       position: "top_right",
                       header: "TEMPERATURE MAISON",
                       config: {
                        groups: [
                         {
                          items: [
                           {
                            notification: "TEMPSALLE",
                            itemTitle: "TEMPSALLE",
                            values: [
                             {
                              valueTitle: "TEMPSALLE",
                    		valueUnit: "C",
                    		jsonpath: "data",
                             },
                            ]
                           },
                          ]
                         },
                        ]
                       },
                      },
                    
                    

                    I have to miss something but I don’t see what

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

                      @ELMAGO Hi, no problem let’s dive deeper. Can you please run the curl command manually on the console and paste the result here, please.

                      E 1 Reply Last reply Reply Quote 0
                      • E Offline
                        ELMAGO @wishmaster270
                        last edited by

                        @wishmaster270

                        There she is
                        7b0d670b-43f1-410d-a6ba-5ce99a1012ed-image.png

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

                          @ELMAGO
                          Sorry, my fault.
                          Can you please remove the v option of the curl command. It needs to be curl -s ....

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