Raspberry Pi setup
-
Hold up. I figured it out. So, what I ended up doing was I created my own script to run triggercmd and then I actually added a small line of code to my desktop autostart file shown below (which was kind of janky and more than likely I'd guess was he wrong way since I'm fairly new'ish with creating my own bash scripts):
Step 1: (to create my script to run triggercmd)
nano touch path/to/myscript.shStep 2: (put inside this file then ctrl+x and "y" to exit and write to file before exiting)
#! /bin/bash
/usr/bin/triggercmdagentStep 3: (then edited my desktop autostart file)
nano ~/.config/lxsession/LXDE-pi/autostartStep 4: (added this line of code in it to direct it to my file with a leading @ symbol before the path I added to the file)
"@/path/to/myscript.sh" < - Without quotes at the bottom of the text file edited aboveNote: Figured I'd share because it likely would take somebody only a minute to do this. I don't know if maybe it was something to do with any of the dependencies or the sequence in which I had installed triggercmd with on my Pi, but I tried quite a few ways. Because I noticed when using the installdaemon.sh script- that it wasn't putting/adding a service in systemd but it was odd because it looked like the server was running when I used systemctl start/enable etc... But figured I'd share my experience and how I'd fixed it tonight. Although maybe not the best method, I wanted to share
-
@kalen-daniel, I didn't provide a method to auto-start the triggercmdagent in the foreground on a Pi. Your method is helpful because it provides a way to do that.
I figured most people would not run X-windows on their Pi's, like my-use case as a garages door opener. In cases like that, you'd run this script as root:
/usr/share/triggercmdagent/app/src/installdaemon.sh
... to install the triggercmdagent as a systemd daemon that would only run background commands.
After you run that script you can stop/start or get a status of the agent with these commands:
systemctl stop triggercmdagent systemctl start triggercmdagent systemctl status triggercmdagent
-
This is rad -thanks Russ. I'm not sure what I did but it wouldn't let me auto-start in the foreground, but could have been a simple hiccup I made along the way, when installing it. I have my pi waking up both my laptop and desktop now and trigger can do a bunch of things with both computers from sleeping/locking/restarting them. Really cool. I'll make a better video now that I got it dialed in as it seems to be incredibly seamless with alexa and setting up a simple command in alexa UI for the virtual smartthings switches. I think stringify or smartthings or harmony needs to buy trigger off you IMO!
-
I have been trying to get this triggercmd to work on my Raspberry Pi all afternoon.
I followed the guide above, but when I run "triggercmd", it just dumps me back to the command line with no other response.
When I try and run: /usr/share/triggercmdagent/app/src/installdaemon.sh, I get:
pi ~$ sudo /usr/share/triggercmdagent/app/src/installdaemon.sh
Failed to issue method call: Unit name triggercmdagent is not valid.
Failed to issue method call: Invalid argument
Failed to issue method call: Unit name triggercmdagent is not valid.I also don't have a commands.json file under /root/.TRIGGERcmdData:
pi ~ $ sudo ls /root/.TRIGGERcmdData -larth
total 12K
drwx------ 5 root root 4.0K Jul 8 14:14 ..
drwxr-xr-x 2 root root 4.0K Jul 8 14:14 .
-rwxr-xr-x 1 root root 220 Jul 8 16:15 triggercmdagent.serviceAny ideas?
Thanks in advance.
-
@jackmonkey, you should be root when you run triggercmdagent and paste in your token, so switch to root with sudo su -. Please try that and do another ls /root/.TRIGGERcmdData -larth.
-
@russ I've got everything set up from your tutorial, but what do you do to actually add or edit triggers? I have done
nano/root/.TRIGGERcmdData/commands.json
But what do I actually need to do to create or edit triggers and commands?
-
@ryan-roberts, you can add a line to that commands.json file like this, to add a command you want to be able to run:
{"trigger":"apt update","command":"apt-get -y update","ground":"background","voice":"update"},
If you find that your changes go away as soon as you save the file, then there's likely some bad json formatting in the file you tried to save. The most common problem is you have a comma on the last line.
-
This post is deleted! -
Hi Russ..
I think those instructions are not valid for the last raspio.
I've got loads of errors that I am not sure how to solve.The following packages have unmet dependencies:
nodejs : Conflicts: nodejs-legacy but 4.8.2~dfsg-1 is to be installed
npm : Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed
Depends: node-ansi-color-table but it is not going to be installed
Depends: node-archy but it is not going to be installed
Depends: node-block-stream but it is not going to be installed
Depends: node-fstream (>= 0.1.22) but it is not going to be installed
Depends: node-fstream-ignore but it is not going to be installed
Depends: node-github-url-from-git but it is not going to be installed
Depends: node-glob (>= 3.1.21) but it is not going to be installed
Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
Depends: node-inherits but it is not going to be installed
Depends: node-ini (>= 1.1.0) but it is not going to be installed
Depends: node-lockfile but it is not going to be installed
Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
Depends: node-gyp (>= 0.10.9) but it is not going to be installed
Depends: node-nopt (>= 3.0.1) but it is not going to be installed
Depends: node-npmlog but it is not going to be installed
Depends: node-once but it is not going to be installed
Depends: node-osenv but it is not going to be installed
Depends: node-read but it is not going to be installed
Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
Depends: node-request (>= 2.25.0) but it is not going to be installed
Depends: node-retry but it is not going to be installed
Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
Depends: node-semver (>= 2.1.0) but it is not going to be installed
Depends: node-sha but it is not going to be installed
Depends: node-slide but it is not going to be installed
Depends: node-tar (>= 0.1.18) but it is not going to be installed
Depends: node-underscore but it is not going to be installed
Depends: node-which but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages. -
@gutopa, I want to try to reproduce that error and fix it. Can you tell me what Raspberry Pi and what OS you're running?
-
Thanks Russ..
I'm using a pi2 B with a fresh install from noob. So I believe it's all the last version of raspbian.
-
Thanks @gutopa.
My Pi2 B died. I have a Pi 3 but I'll try the latest version of NOOBS/Raspbian on my Pi Zero to hopefully reproduce the problem.
EDIT: I was able reproduce the problem, and fortunately there's a simple solution. I updated the instructions above.
I changed this line:
apt-get -y install npm nodejs-legacy
To this:
apt-get -y install npm nodejs
Thank you for reporting the problem.
-
@russ said in Raspberry Pi setup:
systemctl start triggercmdagent
Hi, i'm curious - i use python scripts to trigger my gpio pins on my raspberry... it appears that these are "Foreground" tasks... how do i do this in the background (so that when the pi reboots - it loads automatically again)
Any tips?
-
@atmosphere, in your commands.json file, make the ground field background instead of foreground. That way it will run in the context of the background service.
{ "trigger": "GPIO 6 on", "command": "python /root/gpio6on.py", "ground": "background", "voice": "6 on" },
Run this to install the background service:
/usr/share/triggercmdagent/app/src/installdaemon.sh
-
Hi Russ..
Could you give me some tips about how to remove it from raspbian?
Thank you
-
@gutopa, you could uninstall the Raspberry Pi agent using these commands:
systemctl stop triggercmdagent /usr/share/triggercmdagent/app/src/removedaemon.sh apt remove triggercmdagent
Then you should delete the computer from your account on the website.
-
hello! my end goal is to launch an html file on my raspberry pi 3b+ using IFTTT (i have a small display plugged into my pi on which i'm expecting to see the file). i'm fairly sure i've gotten everything set up correctly in that i can see evidence of the command having run in IFTTT, my TRIGGERcmd dashboard, and in the CLI when i run "systemctl status triggercmdagent".
i have almost no native idea what i am doing, but i'm a pretty good tinkerer and an excellent copy-and-paster so the command i cobbled together is:
{"trigger":"myTriggerName","command":"chromium-browser file:///home/pi/myFile.html","ground":"background","voice":"myTriggerName","allowParams":"false"}when i try to trigger that command via IFTTT or my TRIGGERcmd Triggers list, nothing actually happens other than the three locations i mention above showing some acknowledgement that the command was run. but when i run "chromium-browser file:///home/pi/myFile.html" via the CLI, the file opens in chromium exactly as i expect, so this all leads me to believe i have formatted the command incorrectly somehow.
any help here would be much appreciated!
-
@erin-leiker, I think the problem is you're running the triggercmd agent as a background daemon, and your command is running with "ground": "background", so you can't see the result of your command.
So to make it work, you'll need to:
- Run the agent in the foreground by running the "triggercmdagent" command in a terminal window in X Windows.
- Trigger your command in the foreground with "ground": "foreground" in your commands.json file.
-
@russ thank you for the tips! i did some googling on x windows, and it sounds like it's a way to access or view the pi remotely. do i still need x windows if i have the pi booting to the desktop and i have a screen on it so i can access it directly?
i updated the trigger to "foreground" and tried running triggercmdagent from the cli, but still i just see the log of the command having been run instead of the results of the command (opening that html file).
-
@erin-leiker, that's interesting. You might need to specify the full path of chromium-browser, so your command would be something like:
/path/to/chromium-browser file:///home/pi/myFile.html
To find the path, type this:
which chromium-browser
If you're booting to the GUI, that's X Windows. I'll boot up one of my Pi's and see if I can reproduce the problem you're having.
EDIT: I tried it on my Pi. I found that it worked with or without the full path. I tried /usr/bin/chromium-browser and just chromium-browser and both worked for me, so I don't know what's wrong in your case.
Can you try a simpler command, like echo Testing >> /tmp/test.txt ?
When I did that, it created a /tmp/test.txt file when I remotely ran the command.