Raspberry Pi setup
-
Log into your Raspberry Pi as user pi with password raspberry.
sudo raspi-config
In raspi-config, enable SSH under Advanced Options.
Run "ifconfig | more" to find your IP address.
From your computer, run Putty, and SSH to the IP address.Run these commands via Putty from your computer:
sudo su -
apt-get -y update
apt-get -y upgrade
apt -y install npm nodejs
wget https://agents.triggercmd.com/triggercmdagent_1.0.1_all.deb
dpkg -i triggercmdagent_1.0.1_all.deb
triggercmdagent
( Paste in your token, and press ENTER. )
( Press CTRL-C to quit. )
/usr/share/triggercmdagent/app/src/installdaemon.shNow you should see your Raspberry Pi in your TRIGGERcmd account.
Edit /root/.TRIGGERcmdData/commands.json to add or remove commands. On the Raspberry Pi, you should set ground = background because the background agent you installed (with installdaemon.sh) adds, removes, and runs background commands as root.
For example, the default commands.json file comes with 3 background commands, including this reboot command:
{ "trigger":"Reboot", "command":"shutdown -r", "ground":"background", "voice":"reboot", "allowParams":"false" }
EDIT: I created a Windows script to make it easier to install the Raspbian OS and the agent on a new Pi:
https://www.triggercmd.com/forum/topic/606/windows-script-to-prep-sd-card-for-raspberry-pi-with-triggercmd-agentEDIT 2: I created a Raspberry Pi image with the TRIGGERcmd agent pre-installed.
https://www.triggercmd.com/forum/topic/2474/raspberry-pi-image-with-triggercmd-pre-loaded -
I did all the Steps and edited that TriggercmdData/commands.json but nothing happend.. I only saw that Gnome Editor and everytime I Trigger it nothing happen.... So I deleted the code of that trigger and again... NOTHING... By the way when I startup this Programm it always says no Daemon istall or something . I did that over 100000 Times but it still wont get away. My Question is : Can you give me an example Code so I can look If its all my fault , or do you know whats going on
-
@Nelson-Ishag,
I might know what's going on, but if you post the output when you type this command, it would help:
/usr/share/triggercmdagent/app/src/installdaemon.sh
Notice the "ground":"background" or "ground":"foreground" part of each command in the commands.json data file.
Gnome Editor is a built-in example foreground command, but I don't think Gnome Editor is available on a Raspberry Pi, so that would explain why if you trigger it it doesn't do anything.
I figured most people who use TRIGGERcmd on a Raspberry Pi will likely only be interested in background commands that run in the daemon (aka background service). For example "apt-get -y update".
That said, you can run the agent in foreground mode just by running "triggercmdagent", but you'll want to run different commands than "gedit" (Gnome Editor). If you're running triggercmdagent in an SSH session, you could have it run something like "tail /var/log/messages", and if you're running it in X-Windows, you could have it run a GUI app like "xeyes".
-
@Russ - how did you get triggercmd to autostart with the raspberry pi? Is it possible at this time? I'm playing around with systemd and was curious if you knew off the top of your head if maybe it is an indicator that I didn't set it up correctly or if there was instructions or another post that showed how to autostart it bc I noticed on a few reboots the commands for waking my desktop didn't work and it was bc I had to launch triggercmd manually on my pi. Thanks man!
-
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.