TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Use curl to run a command via the API.

    Instructions
    3
    6
    6.0k
    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.
    • RussR
      Russ
      last edited by Russ

      curl -X POST
      https://www.triggercmd.com/api/run/triggerSave
      -H 'authorization: Bearer (insert token here)'
      -H 'content-type: application/json'
      -d '{"computer":"(insert computer name here)","trigger":"(insert trigger name here)"}'

      Reminder - your computer name is different from your voice trigger for your computer.

      Also, if you run this on Windows, you'll need to download the Windows version of curl, and use double quotes (") instead of single quotes ('). See this article for more about how to do this on Windows.

      Curl works great, but an easier way to trigger commands from the command line is to use the tcmd utility.

      EDIT 2/27/21: Now you can trigger commands on computers people have shared with you. They show up under "Other users's computers."

      EDIT 12/14/2022: Also see this Python code.

      Russell VanderMey

      1 Reply Last reply Reply Quote 0
      • RussR Russ referenced this topic on
      • RussR Russ referenced this topic on
      • David JonesD
        David Jones
        last edited by

        And how would you add a parameter to the trigger? Would it be something like?:

        -d '{"computer":"(insert computer name here)","trigger":"(insert trigger name here)","parameter":"(insert parameter here)"}'
        

        David Jones MVP
        Microsoft WinHEC/IoT/Embedded/App Development MVP
        https://github.com/djaus2
        https://mvp.microsoft.com/en-us/PublicProfile/5000301?
        @IOTMaestro

        tuicemenT RussR 2 Replies Last reply Reply Quote 0
        • tuicemenT
          tuicemen @David Jones
          last edited by tuicemen

          @david-jones It depends on what parameters you want. The on off dim parameters come from Alexa, Google . The parameter option in the commands.json line only excepts true or false.
          If you need another parameter it goes in your command. See how I did it here
          https://www.triggercmd.com/forum/topic/1962/say-room-temperature-and-humidity parameters in my case were 4 and 22

          David JonesD 1 Reply Last reply Reply Quote 0
          • RussR
            Russ @David Jones
            last edited by Russ

            @david-jones, good question, it's actually params instead of parameter.

            Also, instead of curl you could also use the tcmd go cli tool.

            Russell VanderMey

            David JonesD 1 Reply Last reply Reply Quote 0
            • David JonesD
              David Jones @tuicemen
              last edited by David Jones

              @tuicemen Thanks to you both I got it to work. 🙂
              I write the temperature and humidity to a text file as one command in the master script that is called by the RPi TRIGGERcmd command on the RPi. The master then reads it and it gets merged into the curl command. The curl command then activates a TRIGGERcmd command on the desktop that then casts to the Google nest! Nb I am using .NET 6 on the RPi. I'll blog about this in detail in coming days. See blog site (first link).

              David Jones MVP
              Microsoft WinHEC/IoT/Embedded/App Development MVP
              https://github.com/djaus2
              https://mvp.microsoft.com/en-us/PublicProfile/5000301?
              @IOTMaestro

              1 Reply Last reply Reply Quote 1
              • David JonesD
                David Jones @Russ
                last edited by

                @russ Thanks

                David Jones MVP
                Microsoft WinHEC/IoT/Embedded/App Development MVP
                https://github.com/djaus2
                https://mvp.microsoft.com/en-us/PublicProfile/5000301?
                @IOTMaestro

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post