Help with Home Assistant Command
-
Re: How to run commands from Home Assistant
I've inserted this line into my Home Assistant config.yaml file (below), and it does not appear to be running the command at all. The triggercmd agent, running in terminal, doesn't indicate any command is received / executed. I suspect the problem is in the payload line. Of course my actual token is inserted where it should be, indicated by MYTOKEN in the script below.
The title of my trigger, in TRIGGERcmd is "calculator", and it does work, when executed via TRIGGERcmd.
Any suggestions what I've done wrong here:
rest_command: triggercmd_calculator: url: 'https://www.triggercmd.com/api/run/triggerSave' method: "post" content_type: "application/x-www-form-urlencoded" payload: "trigger=calculator&token=(MYTOKEN)"
-
I think all you need to do is include one more parameter in your payload line:
payload: "computer=(MYCOMPUTER)&trigger=calculator&token=(MYTOKEN)"
-
Still not working. I tried it with and without a parenthesis around the trigger word - calculator (see below). Neither work.
It looks like the triggercmdagent never gets the order to run; when I review the run count for the trigger, it never changes after I call the service in Home Assistant.
I've confirmed I'm using the same token that's on file at the DAM-UBUVM computer. Do you have any other thoughts?
Tried with parenthesis, as follows:
rest_command: triggercmd_calculator: url: 'https://www.triggercmd.com/api/run/triggerSave' method: "post" content_type: "application/x-www-form-urlencoded" payload: "computer=(DAM-UBUVM)&trigger=(calculator)&token=(MYTOKEN)"
Tried without parenthesis, as follows:
rest_command: triggercmd_calculator: url: 'https://www.triggercmd.com/api/run/triggerSave' method: "post" content_type: "application/x-www-form-urlencoded" payload: "computer=(DAM-UBUVM)&trigger=calculator&token=(MYTOKEN)"
-
@dean-mcnaughton, sorry I wasn't clear. Parenthesis are not necessary. I think either of these should work:
rest_command: triggercmd_calculator: url: 'https://www.triggercmd.com/api/run/triggerSave' method: "post" content_type: "application/x-www-form-urlencoded" payload: "computer=laptop&trigger=calculator&token=xyz....abc"
rest_command: triggercmd_calculator: url: 'https://www.triggercmd.com/api/run/triggerSave?computer=laptop&trigger=calculator&token=xyz....abc' method: "get" content_type: "application/x-www-form-urlencoded"
Also, the token can come from the token.tkn file on your computer or the Instructions page - either should work.
You could also test with curl like this:
curl "https://www.triggercmd.com/api/run/triggerSave?computer=laptop&trigger=calculator&token=asdf"
-
Thank u! It is working now. Using the post method, this was the payload line that ended up working (no parenthesis were used):
payload: "computer=DAM-UBUVM&trigger=calculator&token=MYTOKEN"
-
@dean-mcnaughton, awesome. Nice job.
-
@russ
Thanks. Really loving this app.In case you're interested, the final application was to automate arming/disarming a home security system for when people arrive or leave the home.
My particular vendor (A-tech security) does not allow integration with home automation systems, like Home Assistant (HA) or SmartThings, but they do allow users to log into their account online to arm/disarm their system.
So, this was the workaround:
- Home Assistant presence sensor with an on/off boolean (toggle) sends command to TRIGGERcmd as follows:
- HA present (toggle on) --> TRIGGERcmd to arm
- HA away (toggle off) --> TRIGGERcmd to disarm
- UI.Vision web extension configured on an always on VM receives the appropriate trigger, from TRIGGERcmd.
- An arm trigger executes a UI.Vision autorun html file that logs in and arms the system.
- A disarm trigger executes a UI.Vision autorun html file that logs in and disarms the system.
- Home Assistant presence sensor with an on/off boolean (toggle) sends command to TRIGGERcmd as follows:
-
@dean-mcnaughton, that's awesome! I'm always interested in use-cases like this. Thanks for sharing.