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

Use curl to run a command via the API.

Instructions
3
6
6.3k
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.
  • R
    Russ
    last edited by Russ Dec 15, 2022, 2:08 AM May 14, 2017, 1:30 AM

    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
    • R Russ referenced this topic on Jan 5, 2022, 10:39 PM
    • R Russ referenced this topic on Jan 5, 2022, 10:40 PM
    • D
      David Jones
      last edited by Jan 26, 2022, 7:17 AM

      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

      T R 2 Replies Last reply Jan 26, 2022, 11:22 AM Reply Quote 0
      • T
        tuicemen @David Jones
        last edited by tuicemen Jan 26, 2022, 1:37 PM Jan 26, 2022, 11:22 AM

        @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

        D 1 Reply Last reply Jan 27, 2022, 11:22 AM Reply Quote 0
        • R
          Russ @David Jones
          last edited by Russ Jan 26, 2022, 1:25 PM Jan 26, 2022, 1:23 PM

          @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

          D 1 Reply Last reply Jan 27, 2022, 11:28 AM Reply Quote 0
          • D
            David Jones @tuicemen
            last edited by David Jones Jan 27, 2022, 11:28 AM Jan 27, 2022, 11:22 AM

            @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
            • D
              David Jones @Russ
              last edited by Jan 27, 2022, 11:28 AM

              @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
              5 out of 6
              • First post
                5/6
                Last post