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 12.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

      Hi @wishmaster270

      I come back here, it will be simpler.

      My code is:

      //INFORMATION HOMEY EUFY
      
      {
         module: "MMM-CommandToNotification",
         disabled: false,
         config: {
          updateInterval: 300,
          commands: [
           
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/ETATEUFY",
                 timeout: 1000,
      			
                 notifications: [
                  "ETATEUFY",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMSALLE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMSALLE",
                  ],
                },
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMPALIER",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMPALIER",
                  ],
                },
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMARRIERE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMARRIERE",
                  ],
                },
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMGARAGE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMGARAGE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMGAUCHE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMGAUCHE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMAVANT",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMAVANT",
                  ],
                },
      {
            script: "/usr/bin/curl",
            args: "-s  http://192.168.100.244:3000/TEMPSALLE",
            timeout: 1000,
            notifications: [
             "TEMPSALLE",
             ],
           },
      
           {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPBUREAU",
                 timeout: 1000,
                 notifications: [
                  "TEMPBUREAU",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHELENA",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHELENA",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHLOUCA",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHLOUCA",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHALAN",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHALAN",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHPARENT",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHPARENT",
                  ],
                },
      {
            	script: "/usr/bin/curl",
            	args: "-s  http://192.168.100.244:3000/AUTBATTMEGANE",
            	timeout: 1000,
            	notifications: [
             	"AUTBATTMEGANE",
             	  ],
           		},
      
           {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/BATTMEGANE",
                 timeout: 1000,
                 notifications: [
                  "BATTMEGANE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/PLUGMEGANE",
                 timeout: 1000,
      			
                 notifications: [
                  "PLUGMEGANE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CHARGEMEGANE",
                 timeout: 1000,
      			
                 notifications: [
                  "CHARGEMEGANE",
                  ],
                },
      
           ]
         },
        },
      

      So I think it launches all requests at the same time, because my server which must answer crashes.

      I wanted to split it like this:

      //INFORMATION HOMEY EUFY
      
      {
         module: "MMM-CommandToNotification",
         disabled: false,
         config: {
          updateInterval: 300,
          commands: [
           
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/ETATEUFY",
                 timeout: 1000,
      			
                 notifications: [
                  "ETATEUFY",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMSALLE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMSALLE",
                  ],
                },
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMPALIER",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMPALIER",
                  ],
                },
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMARRIERE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMARRIERE",
                  ],
                },
      
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMGARAGE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMGARAGE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMGAUCHE",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMGAUCHE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CAMAVANT",
                 timeout: 1000,
      			
                 notifications: [
                  "CAMAVANT",
                  ],
                },
           ]
         },
        },
      
      
      

      and

      //INFORMATION HOMEY EUFY
      
      {
         module: "MMM-CommandToNotification",
         disabled: false,
         config: {
          updateInterval: 300,
          commands: [
           
      
      
      {
            script: "/usr/bin/curl",
            args: "-s  http://192.168.100.244:3000/TEMPSALLE",
            timeout: 1000,
            notifications: [
             "TEMPSALLE",
             ],
           },
      
           {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPBUREAU",
                 timeout: 1000,
                 notifications: [
                  "TEMPBUREAU",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHELENA",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHELENA",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHLOUCA",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHLOUCA",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHALAN",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHALAN",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/TEMPCHPARENT",
                 timeout: 1000,
                 notifications: [
                  "TEMPCHPARENT",
                  ],
                },
      
      
           ]
         },
        },
      
      
      

      and :

      //INFORMATION HOMEY EUFY
      
      {
         module: "MMM-CommandToNotification",
         disabled: false,
         config: {
          updateInterval: 300,
          commands: [
           
      
      
      
      {
            	script: "/usr/bin/curl",
            	args: "-s  http://192.168.100.244:3000/AUTBATTMEGANE",
            	timeout: 1000,
            	notifications: [
             	"AUTBATTMEGANE",
             	  ],
           		},
      
           {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/BATTMEGANE",
                 timeout: 1000,
                 notifications: [
                  "BATTMEGANE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/PLUGMEGANE",
                 timeout: 1000,
      			
                 notifications: [
                  "PLUGMEGANE",
                  ],
                },
      {
                 script: "/usr/bin/curl",
                 args: "-s  http://192.168.100.244:3000/CHARGEMEGANE",
                 timeout: 1000,
      			
                 notifications: [
                  "CHARGEMEGANE",
                  ],
                },
      
           ]
         },
        },
      
      
      

      But it doesn’t work, only the last element appears.

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

        @ELMAGO Hi,

        thats right. The module does not support multi instance configurations.
        You will need to copy the complete module folder and change some things to get it work.
        But to me it looks like your server is stressed with the 16 calls straight after each other. So you do not need more parallelism but less.
        So i will check if i can at a configurable delay after each command to stretch the time the calls get made to your server a little bit.

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

          @wishmaster270

          good morning

          I don’t mind doing it by hand if you explain to me what I need to change

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

            @ELMAGO Hi,

            i just released a new version of the module which has a new option delayNext that can be added to each command.
            The module then starts the command and waits this amount of milliseconds before the next one is processed.
            So in your case you can add a delayNext: 1000 to each of the commands to give your server some time between the calls.

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

              @wishmaster270 you could make it support multi instance easily

              in the modulename.js when u sendSocketNotification… add the module id to the data

              in the node_helper, send the id back

              in the modulename.js in receiveSocketNotification
              check that the returned id matches this instances id

              sendSocketNotification from the node_helper is a broadcast , all instances get it at the same time, thus the need for the check.

              Sam

              How to add modules

              learning how to use browser developers window for css changes

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

                @sdetweil Hi Sam, I will check that for the next release.
                I already added something similar to one of my other modules but did not know that there is a module id already and added a uuid instead.

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

                  @wishmaster270 this.indentifier

                  https://docs.magicmirror.builders/development/core-module-file.html#available-module-instance-properties

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

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

                    @wishmaster270

                    ok, i test

                    1 Reply Last reply Reply Quote 0
                    • BKeyportB BKeyport referenced this topic on
                    • 1
                    • 2
                    • 3
                    • 4
                    • 5
                    • 4 / 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
                      OSZAR »