TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Raspberry Pi setup

    Raspberry Pi
    raspberry pi
    12
    40
    17.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RussR
      Russ @JackMonkey
      last edited by Russ

      @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.

      Russell VanderMey

      1 Reply Last reply Reply Quote 0
      • R
        Ryan Roberts @Russ
        last edited by

        @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?

        RussR 1 Reply Last reply Reply Quote 0
        • RussR
          Russ @Ryan Roberts
          last edited by

          @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.

          Russell VanderMey

          1 Reply Last reply Reply Quote 0
          • A
            Atmosphere
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • G
              gutopa
              last edited by

              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.

              RussR 1 Reply Last reply Reply Quote 0
              • RussR
                Russ @gutopa
                last edited by

                @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?

                Russell VanderMey

                1 Reply Last reply Reply Quote 0
                • G
                  gutopa
                  last edited by gutopa

                  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.

                  RussR 1 Reply Last reply Reply Quote 0
                  • RussR
                    Russ @gutopa
                    last edited by Russ

                    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.

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • A
                      Atmosphere
                      last edited by

                      @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?

                      RussR 1 Reply Last reply Reply Quote 0
                      • RussR
                        Russ @Atmosphere
                        last edited by Russ

                        @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
                        

                        Russell VanderMey

                        1 Reply Last reply Reply Quote 0
                        • G
                          gutopa
                          last edited by

                          Hi Russ..

                          Could you give me some tips about how to remove it from raspbian?

                          Thank you

                          RussR 1 Reply Last reply Reply Quote 0
                          • RussR
                            Russ @gutopa
                            last edited by Russ

                            @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.

                            Russell VanderMey

                            1 Reply Last reply Reply Quote 0
                            • E
                              Erin Leiker
                              last edited by Erin Leiker

                              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!

                              RussR 1 Reply Last reply Reply Quote 0
                              • RussR
                                Russ @Erin Leiker
                                last edited by Russ

                                @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:

                                1. Run the agent in the foreground by running the "triggercmdagent" command in a terminal window in X Windows.
                                2. Trigger your command in the foreground with "ground": "foreground" in your commands.json file.

                                Russell VanderMey

                                E 1 Reply Last reply Reply Quote 0
                                • E
                                  Erin Leiker @Russ
                                  last edited by

                                  @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).

                                  RussR 1 Reply Last reply Reply Quote 0
                                  • RussR
                                    Russ @Erin Leiker
                                    last edited by Russ

                                    @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.

                                    Russell VanderMey

                                    E 1 Reply Last reply Reply Quote 0
                                    • E
                                      Erin Leiker @Russ
                                      last edited by

                                      @russ whew, i think i figured it out! if i'm right, it all comes down to users.

                                      the instructions for installing on a raspberry pi are based on running all the commands/installations as a root user. the "chromuim-browser" command does not work when executed as the root user, only the default "pi" user. so i switched the command from "chromium-browser" to "xdg-open", which does essentially the same thing for my purposes, and it worked! well, almost.

                                      i'm trying to launch an html file, and the mime type is "text/html" which opens with chromium by default for the pi user (yay!), but with the geany text editor for root (boo). i solved this by tweaking the command to run under the pi user, and it works as expected!

                                      {"trigger":"myTriggerName","command":"su - pi -c 'xdg-open /home/pi/myFile.html'","ground":"foreground","voice":"myTriggerName","allowParams":"false"}

                                      the only downside is that there is a noticeable delay in triggering this command. and i also have to open a terminal window, switch to the root user, and then run "triggercmdagent" before i can successfully trigger it. with this info, do you happen to know if/how i can:

                                      1. auto run triggercmdagent on boot? the install instructions seem to state that it will launch in the background on boot, so i changed the command to "background" but no dice. still have to run triggercmdagent from terminal as root.

                                      2. run/install triggercmdagent under the pi user instead of root? i think that would help speed up the execution of the command significantly.

                                      thank you so much!

                                      RussR 1 Reply Last reply Reply Quote 0
                                      • RussR
                                        Russ @Erin Leiker
                                        last edited by Russ

                                        @erin-leiker, please give this a try:

                                        1. Run this as your pi user to allow root to send stuff to your pi user's Xwindows:
                                        xhost si:localuser:root
                                        
                                        1. Install the background service as root with:
                                        /usr/share/triggercmdagent/app/src/installdaemon.sh
                                        
                                        1. Make sure this variable is set when your command runs as root in the context of your triggercmdagent:
                                        export DISPLAY=:0.0
                                        

                                        Your agent will be running in background mode, so the commands need "ground": "background" to run that way.

                                        I suggest testing with galculator. It's an xwindows calculator app.

                                        Russell VanderMey

                                        1 Reply Last reply Reply Quote 0
                                        • RussR
                                          Russ
                                          last edited by Russ

                                          I created a 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-agent

                                          Russell VanderMey

                                          1 Reply Last reply Reply Quote 0
                                          • A
                                            avs2020
                                            last edited by

                                            @Russ said in Raspberry Pi setup:

                                            /usr/share/triggercmdagent/app/src/installdaemon.sh

                                            I followed the steps here, but the list of commands is empty right after install. The command output is:

                                            pi@raspberrypi:~ $ sudo triggercmdagent
                                            Run installdaemon.sh to install the triggercmdagent daemon so it runs during boot
                                            Daemon install: false
                                            No token exists. Login to request one.
                                            prompt: token: ey.........
                                            Token saved for next time.
                                            Tokenfile: /root/.TRIGGERcmdData/token.tkn
                                            ComputerIDfile: /root/.TRIGGERcmdData/computerid.cfg
                                            Logging in with saved token to run foreground tasks.
                                            Computer ID 5eb384a2ee82630019c61bac saved for next time.
                                            Write backup completed.
                                            Initiated command removals
                                            Initiated command adds

                                            |> 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: Wed May 06 2020 20:46:43 GMT-0700 (PDT)

                                            { message: 'Subscribed to 5eb384a2ee82630019c61bac!' }
                                            { message: 'Subscribed to 5eb384a2ee82630019c61bac!' }
                                            Added Gnome Editor
                                            ^C
                                            pi@raspberrypi:~ $ sudo /usr/share/triggercmdagent/app/src/installdaemon.sh
                                            Daemon install: true
                                            Logging in with saved token.
                                            Checking if the 5eb384a2ee82630019c61bac 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 Wed 2020-05-06 20:35:25 PDT; 12min ago
                                            Main PID: 864 (node)
                                            CGroup: /system.slice/triggercmdagent.service
                                            └─864 node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData

                                            May 06 20:35:33 raspberrypi env[864]: (using sails.io.js node SDK @v1.1.13)
                                            May 06 20:35:33 raspberrypi env[864]: Connected at: Wed May 06 2020 20:35:33 GMT-0700 (PDT)
                                            May 06 20:35:33 raspberrypi env[864]: Initiated command removals
                                            May 06 20:35:33 raspberrypi env[864]: { message: 'Subscribed to null!' }
                                            May 06 20:35:33 raspberrypi env[864]: { message: 'Subscribed to null!' }
                                            May 06 20:35:33 raspberrypi env[864]: Initiated command adds
                                            May 06 20:35:33 raspberrypi env[864]: Failed while trying add a trigger.
                                            May 06 20:35:33 raspberrypi env[864]: Failed while trying add a trigger.
                                            May 06 20:35:33 raspberrypi env[864]: Failed while trying add a trigger.
                                            May 06 20:35:33 raspberrypi env[864]: Failed while trying add a trigger.

                                            I have not edited any standard files.

                                            RussR 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post