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

Raspberry Pi setup

Raspberry Pi
raspberry pi
12
40
18.7k
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.
  • E
    Erin Leiker
    last edited by Erin Leiker May 31, 2019, 10:12 PM May 31, 2019, 10:11 PM

    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!

    R 1 Reply Last reply Jun 1, 2019, 1:48 PM Reply Quote 0
    • R
      Russ @Erin Leiker
      last edited by Russ Jun 1, 2019, 1:50 PM Jun 1, 2019, 1:48 PM

      @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 Jun 3, 2019, 2:58 PM Reply Quote 0
      • E
        Erin Leiker @Russ
        last edited by Jun 3, 2019, 2:58 PM

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

        R 1 Reply Last reply Jun 3, 2019, 10:15 PM Reply Quote 0
        • R
          Russ @Erin Leiker
          last edited by Russ Jun 5, 2019, 2:11 AM Jun 3, 2019, 10:15 PM

          @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 Jun 6, 2019, 10:57 PM Reply Quote 0
          • E
            Erin Leiker @Russ
            last edited by Jun 6, 2019, 10:57 PM

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

            R 1 Reply Last reply Jun 7, 2019, 11:47 PM Reply Quote 0
            • R
              Russ @Erin Leiker
              last edited by Russ Jun 7, 2019, 11:52 PM Jun 7, 2019, 11:47 PM

              @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
              • R
                Russ
                last edited by Russ May 3, 2020, 8:11 PM Feb 13, 2020, 2:14 AM

                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 May 7, 2020, 3:51 AM

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

                  R 1 Reply Last reply May 7, 2020, 11:06 PM Reply Quote 0
                  • R
                    Russ @avs2020
                    last edited by May 7, 2020, 11:06 PM

                    @avs2020, it looks like you figured it out because I see commands associated with your raspberrypi computer now. Please confirm.

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • George HatzisymeonG
                      George Hatzisymeon
                      last edited by George Hatzisymeon Sep 5, 2020, 8:09 PM Sep 5, 2020, 8:02 PM

                      It looks like offCommand is never called using this PI/Debian distribution, do you have an update? Did you forget to include this functionality for Linux, it works fine on Windows.

                      R 1 Reply Last reply Oct 16, 2021, 1:58 PM Reply Quote 0
                      • R
                        Russ @George Hatzisymeon
                        last edited by Oct 16, 2021, 1:58 PM

                        @George-Hatzisymeon, sorry I never responded to this. I just noticed it because someone upvoted it.

                        I just verified that the offCommand commands.json value is supported in the current version of the Raspberry Pi agent. If you were using that version and it didn't work, then maybe you were missing this part:

                        "allowParams":"true"
                        

                        Here's an example entry I just tested. It turns my led strip off if the parameter was off, and if the parameter was on, it turns the strip on and makes the leds green.

                            {
                               "trigger":"Green",
                               "command":"\/root\/killrun.sh leds.py green",
                               "offCommand": "\/root\/killrun.sh leds.py off",
                               "ground":"background",
                               "voice":"green",
                               "allowParams":"true"
                            },
                        

                        Russell VanderMey

                        1 Reply Last reply Reply Quote 0
                        • R Russ referenced this topic on Jan 4, 2022, 11:13 PM
                        • tuicemenT tuicemen moved this topic from Instructions on Jan 30, 2022, 7:39 PM
                        • tuicemenT tuicemen pinned this topic on Feb 12, 2022, 3:31 PM
                        • R Russ referenced this topic on May 2, 2022, 10:10 PM
                        • Dean McNaughtonD Dean McNaughton referenced this topic on May 2, 2022, 11:15 PM
                        • Dean McNaughtonD Dean McNaughton referenced this topic on May 4, 2022, 4:05 PM
                        • Dean McNaughtonD Dean McNaughton referenced this topic on May 5, 2022, 11:31 AM
                        • A
                          Ar7hur
                          last edited by Oct 1, 2022, 4:56 PM

                          What I did wrong? It appears:
                          E: Unable to locate package https://agents.triggercmd.com
                          E: Couldn't find any packageb by glob 'https://agents.triggercmd.com'
                          E: Couldn't find any packageb by regex 'https://agents.triggercmd.com'

                          I'm a noob, and sorry for my english.

                          R 1 Reply Last reply Oct 1, 2022, 5:55 PM Reply Quote 0
                          • R
                            Russ @Ar7hur
                            last edited by Russ Oct 1, 2022, 5:56 PM Oct 1, 2022, 5:55 PM

                            @Ar7hur, the URL to download the Raspberry Pi installer is this:

                            https://agents.triggercmd.com/triggercmdagent_1.0.1_all.deb

                            Does that answer your question?

                            Russell VanderMey

                            A 1 Reply Last reply Oct 1, 2022, 6:22 PM Reply Quote 0
                            • A
                              Ar7hur @Russ
                              last edited by Oct 1, 2022, 6:22 PM

                              @Russ I wrote this, but appears what I mentioned

                              R 1 Reply Last reply Oct 1, 2022, 7:04 PM Reply Quote 0
                              • R
                                Russ @Ar7hur
                                last edited by Oct 1, 2022, 7:04 PM

                                @Ar7hur, how do you get those errors? Can you please give me the command you typed, or paste a screenshot?

                                Russell VanderMey

                                A 1 Reply Last reply Oct 1, 2022, 8:39 PM Reply Quote 0
                                • A
                                  Ar7hur @Russ
                                  last edited by Ar7hur Oct 1, 2022, 9:09 PM Oct 1, 2022, 8:39 PM

                                  @Russ It was my mistake. I discovered where was wrong😅 Sorry
                                  How to create a trigger to turn off? and is there how to turn on the pi by voice command?

                                  R 1 Reply Last reply Oct 2, 2022, 2:49 PM Reply Quote 0
                                  • R
                                    Russ @Ar7hur
                                    last edited by Russ Oct 2, 2022, 2:56 PM Oct 2, 2022, 2:49 PM

                                    @Ar7hur, no problem. I'm glad you got it working.

                                    You could create a trigger that runs shutdown --poweroff but it won't actually power the Raspberry Pi off. Raspberry Pi's also do not support wake-on-lan, so you couldn't power it on from another computer on your network like you could with a PC.

                                    The only thing I can think of is you could power the Pi on/off with a relay by connecting/disconnecting the vbus on the 5volt power input with an adapter you could build with something like this, or you could use a smart plug to power it off/on. You could run a command that runs an Alexa routine that powers the smart plug on or off.

                                    Russell VanderMey

                                    1 Reply Last reply Reply Quote 0
                                    • Jorge FuentesJ
                                      Jorge Fuentes
                                      last edited by Nov 26, 2022, 4:28 PM

                                      Hello, first of all thanks for this amazing integration/work.

                                      I've a question:

                                      Do you know if there's a way to add a parameter over the "commands.json" file in order to make Alexa speak when you execute the trigger? So she'll reply when you do a query. Would be great so it could be integrated with some bash scripts/ansible playbooks.

                                      Thank you,
                                      Kind regards.

                                      R 1 Reply Last reply Nov 26, 2022, 5:35 PM Reply Quote 0
                                      • R
                                        Russ @Jorge Fuentes
                                        last edited by Russ Nov 26, 2022, 5:57 PM Nov 26, 2022, 5:35 PM

                                        @Jorge-Fuentes, yes, there is a way.

                                        You can use the Voice Reply field to do that.

                                        This article explains how.

                                        Basically, put "{{result}}" in your voicereply field and run the sendresult script that the TRIGGERcmd agent installs here:

                                        Windows:

                                        %USERPROFILE%\.TRIGGERcmdData\sendresult.bat
                                        

                                        Linux / Mac:

                                        ~/.TRIGGERcmdData/sendresult.sh
                                        

                                        I know you're on a Raspberry Pi, but I'm pasting the Windows GUI editor screenshot just to make sure the concept is clear.

                                        f3d13688-7d34-434a-874d-2168e6ef7daa-image.png

                                        In the runs list you can see what the "sendresult" script is sending back to the server as the "result" of the command you ran. If you include {{result]] in the Voice Reply field, The TC, TRIGGERcmd, or Trigger Command Alexa skills will say that text when you use one of those skills to trigger the command.
                                        eb58845e-a91a-4835-bd03-15f7e9127f74-image.png

                                        Instead of making the command in the commands.json file directly run the sendresult script, normally the commands.json would reference a script that would run the sendresult script last, and send back the value of an environment variable like this:

                                        ~/.TRIGGERcmdData/sendresult.sh ${RESULT}
                                        

                                        The one problem with the above method is it uses one of the non-smart home TRIGGERcmd Alexa skills. Those skills are not as reliable at matching the words in the sentence pattern it uses to run the command. The TRIGGERcmd Smart Home Alexa skill does a much better job.

                                        TC / TRIGGERcmd / Trigger Command Alexa skill pattern:

                                        • Alexa, ask TRIGGERcmd to run Calculator

                                        TRIGGERcmd Smart Home Alexa skill pattern:

                                        • Alexa, turn on Calculator

                                        If you want to use the TRIGGERcmd Smart Home skill to run your command, you use this method.

                                        Russell VanderMey

                                        Jorge FuentesJ 1 Reply Last reply Nov 26, 2022, 6:19 PM Reply Quote 0
                                        • Jorge FuentesJ
                                          Jorge Fuentes @Russ
                                          last edited by Nov 26, 2022, 6:19 PM

                                          That's brilliant, thank you for the information.

                                          1 Reply Last reply Reply Quote 0
                                          • R Russ referenced this topic on Jun 1, 2023, 12:35 PM
                                          • R Russ referenced this topic on Dec 16, 2024, 1:22 PM
                                          • First post
                                            Last post