• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.1k 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.
  • W Offline
    wishmaster270 Module Developer @ELMAGO
    last edited by wishmaster270 Nov 23, 2022, 6:37 PM Nov 23, 2022, 6:35 PM

    @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 Nov 23, 2022, 7:46 PM Reply Quote 0
    • E Offline
      ELMAGO @wishmaster270
      last edited by Nov 23, 2022, 7:46 PM

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

      W 1 Reply Last reply Nov 23, 2022, 8:05 PM Reply Quote 0
      • W Offline
        wishmaster270 Module Developer @ELMAGO
        last edited by wishmaster270 Nov 23, 2022, 8:06 PM Nov 23, 2022, 8:05 PM

        @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 Nov 24, 2022, 5:29 PM Reply Quote 0
        • E Offline
          ELMAGO @wishmaster270
          last edited by Nov 24, 2022, 5:29 PM

          @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

          W 1 Reply Last reply Nov 24, 2022, 5:30 PM Reply Quote 0
          • W Offline
            wishmaster270 Module Developer @ELMAGO
            last edited by Nov 24, 2022, 5:30 PM

            @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 Nov 24, 2022, 5:32 PM Reply Quote 0
            • E Offline
              ELMAGO @wishmaster270
              last edited by Nov 24, 2022, 5:32 PM

              @wishmaster270

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

              W 1 Reply Last reply Nov 24, 2022, 5:35 PM Reply Quote 0
              • W Offline
                wishmaster270 Module Developer @ELMAGO
                last edited by Nov 24, 2022, 5:35 PM

                @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 Nov 24, 2022, 5:38 PM Reply Quote 0
                • E Offline
                  ELMAGO @wishmaster270
                  last edited by Nov 24, 2022, 5:38 PM

                  @wishmaster270

                  It’s same

                  //TEMPERATURE MAISON
                  
                  {
                     module: "MMM-CommandToNotification",
                     disabled: false,
                     config: {
                      updateInterval: 10,
                      commands: [
                       {
                        script: "/usr/bin/curl",
                        args: "-s  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",
                           },
                          ]
                         },
                        ]
                       },
                      ]
                     },
                    },
                  
                  
                  W 1 Reply Last reply Nov 24, 2022, 6:07 PM Reply Quote 0
                  • W Offline
                    wishmaster270 Module Developer @ELMAGO
                    last edited by wishmaster270 Nov 24, 2022, 6:08 PM Nov 24, 2022, 6:07 PM

                    @ELMAGO
                    Sorry, took me a moment to set up a test environment…
                    I think if your webserver is not very very fast you need to increase the timeout value in the command module.
                    The timeout is in milliseconds and you configured 5. I guess it should be 5000.
                    This config works fine in my development environment.

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

                    Edit: I increased the updateInterval to 60

                    E 1 Reply Last reply Nov 25, 2022, 2:51 PM Reply Quote 0
                    • E Offline
                      ELMAGO @wishmaster270
                      last edited by Nov 25, 2022, 2:51 PM

                      @wishmaster270
                      You are phenomenal…but I still have three problems:
                      1 - When I look for several values, it only shows me the first one.
                      2- The Celsius symbol does not seem to be accepted

                      76b9ae31-734f-49b5-a4be-5cbf0490a0be-image.png

                      3- 3- If I may abuse…is it possible to do the same formatting as this one. CSS and me…

                      7e8bc18c-c15d-46ab-a37d-4f7782032f2f-image.png

                      Here is my code :

                      //TEMPERATURE MAISON
                      
                      {
                         module: "MMM-CommandToNotification",
                         disabled: false,
                         config: {
                          updateInterval: 60,
                          commands: [
                           {
                            script: "/usr/bin/curl",
                            args: "-s  http://192.168.100.244:3000/TEMPSALLE",
                            timeout: 5000,
                            notifications: [
                             "TEMPSALLE",
                             ],
                      	
                           },
                           ]
                         },
                        },
                      
                      {
                         module: "MMM-CommandToNotification",
                         disabled: false,
                         config: {
                          updateInterval: 60,
                          commands: [
                           {
                            script: "/usr/bin/curl",
                            args: "-s  http://192.168.100.244:3000/TEMPBUREAU",
                            timeout: 5000,
                            notifications: [
                             "TEMPBUREAU",
                             ],
                      	
                           },
                           ]
                         },
                        },
                      
                      
                      // AFFICHAGE
                      
                      {
                         module: "MMM-ValuesByNotification",
                         position: "top_right",
                         header: "TEMPERATURE MAISON",
                         config: {
                          groups: [
                           {
                            items: [
                             {
                              notification: "TEMPSALLE",
                              values: [
                               {
                                valueTitle: "SALLE A MANGER",
                      		valueUnit: "°C",
                      		jsonpath: "data",
                               },
                              ]
                             },
                      	          {
                              notification: "TEMPBUREAU",
                              values: [
                               {
                                valueTitle: "BUREAU",
                      		valueUnit: "°C",
                      		jsonpath: "data",
                               },
                              ]
                             },
                            ]
                           },
                          ]
                         },
                        },
                      
                      

                      Once again thank you for everything.

                      W 1 Reply Last reply Nov 25, 2022, 5:48 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 1 / 5
                      1 / 5
                      • First post
                        8/41
                        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