Use curl to run a command via the API.
-
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.
-
-
-
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 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-jones, good question, it's actually params instead of parameter.
Also, instead of curl you could also use the tcmd go cli tool.
-
@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). -
@russ Thanks