Contents of command.json getting lost
-
I am running HomeGenie on a Pi Zero W but cannot get it to work with Alexa through TriggerCMD. TriggerCMD shows the only trigger as being Gnome, yet my command.json file is as follows:
[
{"trigger":"apt update","command":"apt-get -y update","ground":"background","voice":"update"},
{"trigger":"Front Tablelamp",
"command":"/home/pi/scripts/hg.sh X10 L4",
"ground":"background",
"voice":"Front Tablelamp",
"allowParams":"false"},
{"trigger":"Carport Light",
"command":"/home/pi/scripts/hg.sh X10 L2",
"ground":"background",
"voice":"Carport Light",
"allowParams":"false"},
{"trigger":"Workshop Light",
"command":"/home/pi/scripts/hg.sh X10 L3",
"ground":"background",
"voice":"Workshop Light",
"allowParams":"false"}
]
Each of these commands turns on and off lights when entered from the command line. I thought TriggerCMD would find these in its search and overwrite the Gnome editor command. Can you tell me what I am doing wrong? -
I meant "commands.json". Duh!
-
@draddog, if you've already setup your data files, including commands.json under /root/.TRIGGERcmdData, you can install the background agent like this:
sudo su - /usr/share/triggercmdagent/app/src/installdaemon.sh
It's probably not obvious, but it's part of these instructions for the Raspberry Pi:
https://www.triggercmd.com/forum/topic/12/raspberry-pi-setup?_=1685535650655The reason you see the Gnome Editor command is it was the foreground command in your original commands.json file when you installed the agent. The first time you run the agent, it runs in foreground mode, but generally, on Raspberry Pi you want to install the background agent to run as root.
-
Actually, I did enter the commands you gave me several times, but the Gnome editor persisted to be the only trigger. I just tried it again, but the Gnome editor trigger did not go away. I deleted my RasPi computer from my Triggercmd account to try to rebuild anew. Now I have no triggers. I re-executed the command-set to re-load Triggercmd and I still have no triggers. The commands I re-executed are:
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
sudo su -
triggercmdagent
sudo su -
/usr/share/triggercmdagent/app/src/installdaemon.shAt least the pesky Gnome editor trigger is gone. I went to my Alexa app and deleted all Smart Home devices and tried to re-Discover devices. None were found. I suspect I am making some dumb mistake, but I cannot get it to work.
-
@draddog, something must have gone wrong when you ran this command because the background agent doesn't seem to be running.
/usr/share/triggercmdagent/app/src/installdaemon.sh
Can you re-run that and copy/paste the output here?
Also, can you show me the output when you run this command?
systemctl status triggercmdagent
And this command?
cat /root/.TRIGGERcmdData/debug.log
And this one?
triggercmdagent
Before you run those commands, run this one to switch to the root user:
sudo su -
Thanks for your patience. I think we can figure this out.
-
OK, I ran the 4 commands you requested and the results are as follows:
root@Gremlin:~# sudo su -
root@Gremlin:~# /usr/share/triggercmdagent/app/src/installdaemon.sh
Daemon install: true
Logging in with saved token.
Checking if the 6478e95100289c001b4fb9b9 computer exists.
This computer exists in your account.
● triggercmdagent.service - TRIGGERcmd Agent
Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vend>
Active: active (running) since Thu 2023-06-01 10:15:58 EDT; 11h ago
Main PID: 328 (node)
Tasks: 11 (limit: 414)
CPU: 37.168s
CGroup: /system.slice/triggercmdagent.service
└─328 node /usr/share/triggercmdagent/app/src/daemon.js --run /roo>Jun 01 10:16:48 Gremlin env[328]: Logging in with saved token to run background>
Jun 01 10:16:55 Gremlin env[328]: Write backup completed.
Jun 01 10:16:56 Gremlin env[328]: |> Now connected to https://www.triggerc>
Jun 01 10:16:56 Gremlin env[328]: ___/ For help, see: http://bit.ly/2q0QDpf
Jun 01 10:16:56 Gremlin env[328]: (using sails.io.js node SDK @v1.1.13)
Jun 01 10:16:56 Gremlin env[328]: Connected at: Thu Jun 01 2023 10:16:>
Jun 01 10:16:57 Gremlin env[328]: { message: 'Subscribed to 646fec86bda2b8001ac>
Jun 01 10:16:57 Gremlin env[328]: { message: 'Subscribed to 646fec86bda2b8001ac>
Jun 01 10:16:57 Gremlin env[328]: Initiated command adds
Jun 01 10:16:57 Gremlin env[328]: Initiated command removals
lines 1-19/19 (END)
^C
root@Gremlin:~# systemctl status triggercmdagent
● triggercmdagent.service - TRIGGERcmd Agent
Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vend>
Active: active (running) since Thu 2023-06-01 10:15:58 EDT; 11h ago
Main PID: 328 (node)
Tasks: 11 (limit: 414)
CPU: 37.201s
CGroup: /system.slice/triggercmdagent.service
└─328 node /usr/share/triggercmdagent/app/src/daemon.js --run /roo>Jun 01 10:16:48 Gremlin env[328]: Logging in with saved token to run background>
Jun 01 10:16:55 Gremlin env[328]: Write backup completed.
Jun 01 10:16:56 Gremlin env[328]: |> Now connected to https://www.triggerc>
Jun 01 10:16:56 Gremlin env[328]: ___/ For help, see: http://bit.ly/2q0QDpf
Jun 01 10:16:56 Gremlin env[328]: (using sails.io.js node SDK @v1.1.13)
Jun 01 10:16:56 Gremlin env[328]: Connected at: Thu Jun 01 2023 10:16:>
Jun 01 10:16:57 Gremlin env[328]: { message: 'Subscribed to 646fec86bda2b8001ac>
Jun 01 10:16:57 Gremlin env[328]: { message: 'Subscribed to 646fec86bda2b8001ac>
Jun 01 10:16:57 Gremlin env[328]: Initiated command adds
Jun 01 10:16:57 Gremlin env[328]: Initiated command removals
lines 1-19/19 (END)
^C
root@Gremlin:~# cat /root/.TRIGGERcmdData/debug.log
cat: /root/.TRIGGERcmdData/debug.log: No such file or directory
root@Gremlin:~# triggercmdagent
Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
Daemon install: false
Logging in with saved token.
Checking if the 6478e95100289c001b4fb9b9 computer exists.
This computer exists in your account.
Tokenfile: /root/.TRIGGERcmdData/token.tkn
ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
Logging in with saved token to run foreground tasks.
Write backup completed.|> Now connected to https://www.triggercmd.com.
___/ For help, see: http://bit.ly/2q0QDpf
(using sails.io.js node SDK @v1.1.13)
Connected at: Thu Jun 01 2023 22:13:35 GMT-0400 (Eastern Daylight Time)Initiated command removals
{ message: 'Subscribed to 6478e95100289c001b4fb9b9!' }
{ message: 'Subscribed to 6478e95100289c001b4fb9b9!' }
Initiated command adds
^C
root@Gremlin:~# -
@draddog, the background agent seems to be running fine, and according to the commands.json content you showed me above, your commands are all background commands, so they should show up in your account.
Can you also run this command to confirm those commands are in the correct commands.json file?
cat /root/.TRIGGERcmdData/commands.json
I wonder if you were showing me a different commands.json file. If those commands are in /home/pi/.TRIGGERcmdData/commands.json, just copy it to the one in the /root/.TRIGGERcmdData directory because that's the one the your background agent uses.
You're probably aware of this, but I notice you have two different TRIGGERcmd accounts with two different computers in them. The computer with ID 647772575231f2001b60f808 still exists with that Gnome Editor command, and the computer with ID 6478e95100289c001b4fb9b9 that your background agent is using has no commands. Just mentioning it to make sure you're not confusing the two accounts.
-
Yes, I'm aware that I have two TRIGGERcmd accounts. While I was struggling to get TRIGGERcmd to work, before I requested your help, I created the second account to test if I might have screwed up setting it up. Obviously, this did not resolve the problem. Both accounts were set up for the same RasPi computer, "Gremlin", so only one was active at a time. Consequently, I do not believe that I am getting them confused. However, the contents of the commands.json file below that you requested has a trigger for "Reboot" which was not in the file I sent to you above. I did this to have a way to distinguish them.
Here are the results that you requested:
root@Gremlin:~# cat /root/.TRIGGERcmdData/commands.json
[
{"trigger":"Reboot","command":"shutdown -r","ground":"background","voice":"reboot","allowParams": "false"},
{"trigger":"apt update","command":"apt-get -y update","ground":"background","voice":"update","allowParams": "false"},
{"trigger":"Front Tablelamp",
"command":"/home/pi/scripts/hg.sh X10 L4",
"ground":"background",
"voice":"Front Tablelamp",
"allowParams":"false"},
{"trigger":"Carport Light",
"command":"/home/pi/scripts/hg.sh X10 L2",
"ground":"background",
"voice":"Carport Light",
"allowParams":"false"},
{"trigger":"Workshop Light",
"command":"/home/pi/scripts/hg.sh X10 L3",
"ground":"background",
"voice":"Workshop Light",
"allowParams":"false"}
]
root@Gremlin:~# -
Russ, is there any other information that you need or anything else that I can do or provide to help determine what to do to get my commands.json commands into TRIGGER.cmd on my RasPi Zero W?