Raspberry Pi set commands
-
Hi,
I successfully installed triggercmd on my Raspberry Pi 4.
I also changed/added a command under ~/.TRIGGERcmdData/commands.json, but under the Trigger Section on the Website, there ist still only the "Gnome Editor" command (which I deleted).
What's wrong?
Thanks for your help. -
@Oliver-Oßwald, Gnome Editor is the only built-in foreground command, and when you ran the agent in foreground mode to install the token, it added that command, but in general on a Raspberry Pi you want to use the background service that runs when the Pi boots, and runs commands with ground = background.
You can install it with these commands:
sudo su - /usr/share/triggercmdagent/app/src/installdaemon.sh
After you install the background service, your command will likely show up because it's probably a background command.
-
Thanks for your reply.
I run also the installdaemon script, but it didn't help.
Here is my commands.json:[ {"trigger":"neustarten","command":"sudo shutdown -r","ground":"background","voice":"Raspi startet neu","allowParams": "false"}, {"trigger":"herunterfahren","command":"sudo shutdown -h now", "ground":"background","voice":"Raspi fährt herunter","allowParams":"false"} {"trigger":"neustarten","command":"sudo shutdown -r","ground":"foreground","voice":"Raspi startet neu","allowParams": "false"}, {"trigger":"herunterfahren","command":"sudo shutdown -h now", "ground":"foreground","voice":"Raspi fährt herunter","allowParams":"false"} ]
The foreground commands are only for testing
-
@Oliver-Oßwald, maybe you ran the triggercmdagent as your pi user, so you probably have a /home/pi/.TRIGGERcmdData folder that corresponds with the computer you see in your account. That's a common problem. It happens if you didn't run sudo su - before running the triggercmdagent.
You could verify this by hovering over your computer name on the website, and compare the computer_id with the computer ID you see in /home/pi/.TRIGGERcmdData/computerid.cfg
https://www.triggercmd.com/user/command/list?computer_id=59dfghb580ec83142421123e
If you run this command:
ps -ef | grep triggercmdagent
You should see the agent is running with this command. Notice it uses /root/.TRIGGERcmdData. That's because the installdaemon.sh script installs it to run as root, and to use the /root folder as the home folder.
node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData
BTW, that commands.json file looks good, although I see your foreground commands are named the same as your background commands, so if you run the foreground agent, it will add the foreground commands and it will be difficult to tell the difference.
-
Hey,
I tried it out, but it doesn't help.Here are the commands I run:
dpkg -i triggercmdagent_1.0.1_all.deb sudo su triggercmdagent nano /root/.TRIGGERcmdData/commands.json _____ [ {"trigger":"neustarten","command":"sudo shutdown -r","ground":"background","voice":"Raspi neustarten","allowParams": "false"}, {"trigger":"herunterfahren","command":"sudo shutdown -h now", "ground":"background","voice":"Raspi herunterfahren","allowParams":"false"}, {"trigger":"neustarten2","command":"sudo shutdown -r","ground":"foreground","voice":"Raspi neustarten","allowParams": "false"}, {"trigger":"herunterfahren2","command":"sudo shutdown -h now", "ground":"foreground","voice":"Raspi herunterfahren","allowParams":"false"} ] _____ /usr/share/triggercmdagent/app/src/installdaemon.sh
And here is the output:
root@raspi:/home/pi# /usr/share/triggercmdagent/app/src/installdaemon.sh Daemon install: true Logging in with saved token. Checking if the ********** computer exists. This computer exists in your account. * triggercmdagent.service - TRIGGERcmd Agent Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-05-25 15:47:58 CEST; 52min ago Main PID: 2491 (node) Tasks: 11 (limit: 4915) Memory: 22.6M CGroup: /system.slice/triggercmdagent.service `-2491 node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData Mai 25 16:02:22 raspi env[2491]: at tryOnTimeout (timers.js:300:5) Mai 25 16:02:22 raspi env[2491]: at listOnTimeout (timers.js:263:5) Mai 25 16:02:22 raspi env[2491]: at Timer.processTimers (timers.js:223:10) Mai 25 16:02:22 raspi env[2491]: Restoring the last known good file Mai 25 16:02:22 raspi env[2491]: Restore backup completed. Mai 25 16:02:23 raspi env[2491]: Write backup completed. Mai 25 16:02:24 raspi env[2491]: Initiated command removals Mai 25 16:02:24 raspi env[2491]: Initiated command adds Mai 25 16:02:24 raspi env[2491]: Failed while trying add a trigger. Mai 25 16:02:24 raspi env[2491]: Failed while trying add a trigger.
-
@Oliver-Oßwald, I see this in your output:
Failed while trying add a trigger.
I suspect you deleted the computer referenced in /root/.TRIGGERcmdData/computerid.cfg from your account, so the agent can't add commands to it. Assuming that's the case, I recommend these steps:
sudo su - systemctl stop triggercmdagent cp /root/.TRIGGERcmdData/commands.json /root rm -rf /root/.TRIGGERcmdData triggercmdagent # (enter your token) # CTRL-C to exit the foreground agent systemctl start triggercmdagent systemctl status triggercmdagent # Test it
-
Thanks a lot, it seems to work!
-
@Oliver-Oßwald, awesome.