TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. Russ
    • Profile
    • Following 1
    • Followers 42
    • Topics 217
    • Posts 2,578
    • Best 164
    • Controversial 6
    • Groups 1

    Russ

    @Russ

    administrators

    I'm a tech enthusiast with about 30 years experience in IT. Recently I'm also a TRIGGERcmd developer.

    161
    Reputation
    3.8k
    Profile views
    2.6k
    Posts
    42
    Followers
    1
    Following
    Joined Last Online
    Website triggercmd.com Location Haslett, MI

    Russ Unfollow Follow
    administrators

    Best posts made by Russ

    • RE: Laptop Battery Management - Automated On/Off Cycle

      @philip-nguyen, there's a similar question here.

      These are the high level steps:

      1. Create 2 commands that just run echo (doesn't matter what), and name them PlugOn and PlugOff.
      2. Setup two Alexa routines - one that turns on your smart plug when the PlugOn command runs, and other that turns it off when the PlugOff command runs.
      3. Create a script. At the beginning of the script, do the following:
      4. Set variable called PLUG_IS_ON with a default value of true.
      5. To make sure the plug is on at first, run the tcmd utility like this: tcmd -t plugon -c (your TRIGGERcmd computer name)
      6. Create a loop that repeats every minute. Inside the loop, do the following:
      7. Check your battery level with BatteryInfoView.exe
      8. When the level is below 30 percent and PLUG_IS_ON = false, run tcmd utility like this: tcmd -t plugon -c (your TRIGGERcmd computer name)
      9. When the level is above 99 percent and PLUG_IS_ON = true, run tcmd utility like this: tcmd -t plugoff -c (your TRIGGERcmd computer name)
      10. Also set PLUG_IS_ON to true when you run plugon, and set it to false when you run plugoff

      I think that should work. Do you know how to do that? Let me know if you get stuck, and where you get stuck. I can look at your script if you paste it here.

      posted in Example Commands
      RussR
      Russ
    • List of ways to trigger your commands

      You can use this web page of course, but don't stop there. Check out this list of ways to run your commands on your computers.

      The Smart Home version of the Alexa skill and Google Assistant action does the best job of matching your spoken words to your commands.

      Smart Home voice assistant skills (Example: "Alexa, turn on calculator") <--Recommended

      • "TRIGGERcmd Smart Home" Alexa skill
      • "TRIGGERcmd Smart Home" Google Assistant action

      Original "conversational" voice assistant skills (Example: "Alexa, ask TRIGGERcmd to run calculator"):

      • Original Alexa skill
      • Original Google Assistant action (deprecated)

      Progressive Web App (PWA)

      • https://app.triggercmd.com

      Mobile apps:

      • Apple App Store: TRIGGERcmd
      • Google Play Store: TRIGGERcmd (supports widgets)
      • Amazon App Store: TRIGGERcmd

      Run your commands when things happen in other Internet services:

      • Zapier - create a "Zap" that runs your command when something happens on one of their 1500+ supported apps.
      • Make - create "scenarios" that run commands on your computers.
      • IFTTT - If This Then run a command, or if a TRIGGERcmd command runs, run an IFTTT applet.
      • Microsoft Power Automate (aka Flow) - run commands when things happen in Office 365 and other services.
      • Pipedream - build workflows that run your commands.

      IoT Smart Home hubs:

      • Home Assistant - Flip virtual HA switches to run your TRIGGERcmd commands.
      • Samsung SmartThings - Create virtual switches for each command, then flip the switches to run them.
      • Homey - Use the ‘run command’ flow action.
      • Hubitat - Trigger a command like you'd flip a switch.
      • Node-RED - Run commands using an "http request".
      • HomeKit - Use the homebridge-http-switch plugin with a bookmark URL.

      Other cool stuff:

      • Run an Alexa routine - when one of your TRIGGERcmd commands runs.
      • Google Assistant routine (aka automation) - use one of your TRIGGERcmd commands as a "starter" to run your routine when the command runs, or run one of your commands as a routine's "action." Either way, you must use the google automations script editor, not the Home app.
      • Bookmarks - Create and share URL's that run your commands without authentication. You can set an optional timeout to make bookmark URL's expire. People can also scan your bookmark's QR code to run the command.
      • iOS shortcut - Use the iOS Shortcuts app to run your commands with Siri.
      • REST API - Use curl or other client to call the TRIGGERcmd API.
      • tcmd - Command line tool written in Go.
      • Tasker - Tasker is an Android app for automating things with your phone.
      • Slack app - Run your commands with Slack "slash" commands.
      • Powershell - Run a command on a computer across the Internet from your powershell script.
      • Roku channel - Run a command from your Roku.
      • Unity - Run a command from a Unity game or utility you made.
      • Streamdeck - Configure a Streamdeck button to run a command on a remote computer.
      • Python - Run a command on a remote computer from a python script.
      • Paywall URL's - Similar to bookmark URL's, you can also charge people via Paypal to run your commands.
      posted in Instructions trigger methods
      RussR
      Russ
    • Autohotkey script for Play, Pause, Volume Up/Down, Next/Previous

      You'll need to install this on your Windows box to make it work: https://autohotkey.com

      This is my media.ahk autohotkey script:

      Gosub, %1%
      return

      next:
      Send {Media_Next}
      return

      previous:
      Send {Media_Prev}
      return

      pause:
      Send {Media_Play_Pause}
      return

      play:
      Send {Media_Play_Pause}
      return

      stop:
      Send {Media_Stop}
      return

      volup:
      Send {Volume_Up}
      return

      voldown:
      Send {Volume_Down}
      return

      mute:
      Send {Volume_Mute}
      return

      These are the corresponding commands.json entries:

      {"trigger":"Mute","command":"start C:\\autohotkeyscripts\\media.ahk mute","ground":"foreground","voice":"mute"},
      {"trigger":"Volume Up","command":"start C:\\autohotkeyscripts\\media.ahk volup","ground":"foreground","voice":"volume up"},
      {"trigger":"Volume Down","command":"start C:\\autohotkeyscripts\\media.ahk voldown","ground":"foreground","voice":"volume down"},
      {"trigger":"Media Next","command":"start C:\\autohotkeyscripts\\media.ahk next","ground":"foreground","voice":"next"},
      {"trigger":"Media Stop","command":"start C:\\autohotkeyscripts\\media.ahk stop","ground":"foreground","voice":"stop"},
      {"trigger":"Media Previous","command":"start C:\\autohotkeyscripts\\media.ahk previous","ground":"foreground","voice":"previous"},
      {"trigger":"Media Play Pause","command":"start C:\\autohotkeyscripts\\media.ahk pause","ground":"foreground","voice":"pause"},

      NOTE: You don't need a Play and a Pause because they do the same thing - they just toggle between play and pause.

      This is optional, but I'm also using my Raspberry Pi based IR receiver to trigger the above commands with a VCR remote.

      I have these entries in my /etc/lirc/lircrc file on the Pi:

        begin
             prog = irexec
             button = KEY_1
             config = export HOME=/root ; /root/triggertest.sh play downstairs
        end
        begin
             prog = irexec
             button = KEY_2
             config = export HOME=/root ; /root/triggertest.sh notepad downstairs
        end
        begin
             prog = irexec
             button = KEY_PLAY
             config = export HOME=/root ; /root/triggertest.sh "Media Play Pause" downstairs
        end
        begin
             prog = irexec
             button = KEY_PAUSE
             config = export HOME=/root ; /root/triggertest.sh "Media Play Pause" downstairs
        end
        begin
             prog = irexec
             button = KEY_RIGHT
             config = export HOME=/root ; /root/triggertest.sh "Media Next" downstairs
        end
        begin
             prog = irexec
             button = KEY_LEFT
             config = export HOME=/root ; /root/triggertest.sh "Media Previous" downstairs
        end
        begin
             prog = irexec
             button = KEY_STOP
             config = export HOME=/root ; /root/triggertest.sh "Media Stop" downstairs
        end
        begin
             prog = irexec
             button = KEY_UP
             config = export HOME=/root ; /root/triggertest.sh "Volume Up" downstairs
        end
        begin
             prog = irexec
             button = KEY_DOWN
             config = export HOME=/root ; /root/triggertest.sh "Volume Down" downstairs
        end
        begin
             prog = irexec
             button = KEY_MUTE
             config = export HOME=/root ; /root/triggertest.sh "Mute" downstairs
        end
      
      posted in Windows
      RussR
      Russ
    • RE: Doc Api

      @Ruan-Santana, I added two pages to the documentation this morning:

      https://docs.triggercmd.com/#/./API/TriggerCommand
      https://docs.triggercmd.com/#/./API/ListCommands

      Is that what you're looking for?

      posted in API
      RussR
      Russ
    • RE: New Bookmark option for each trigger

      @tim-s, that's right - you could even just change the trigger name and change it back, and it would invalidate the bookmark URL.

      posted in Announcements
      RussR
      Russ
    • RE: Shutdown não funciona no mac

      @Waldex-Santos, I think this should work:

      osascript -e 'delay 60' -e 'tell app "System Events" to shut down'
      
      posted in Mac
      RussR
      Russ
    • RE: Triggercmd smart home not reachable

      It's back up now.

      One of my servers went down last night, and Kubernetes didn't handle the fail-over well.

      I got an email from my monitoring system while I was sleeping. I'll need to setup something else that will actually wake me up.

      I'm sorry about this outage.

      posted in Google Home
      RussR
      Russ
    • Hubitat integration

      @Royski created this Hubitat integration that works just like the SmartThings integration.

      His write up is here, on the Hubitat community forum:
      https://community.hubitat.com/t/release-triggercmd-for-hubitat/22715

      The code and instructions are here:
      https://github.com/rvmey/HubitatTRIGGERcmd

      Here's quick video showing it working:
      https://youtu.be/V90B7jbEYxI

      posted in Instructions
      RussR
      Russ
    • Alexa bug fixed

      Some of you might have noticed, when you'd say something like:

      Alexa, ask TRIGGER cmd to run notepad on downstairs

      You'd get an answer like this:

      "Could not find a command with voice word cmd notepad on downstairs, ..."

      I fixed that today.

      For some reason Alexa started sending the "cmd" part of "TRIGGER cmd" as a prefix in the command name. I actually had to add code to strip that out.

      posted in Announcements
      RussR
      Russ
    • RE: How can I get feedback that the command was executed remotely?

      @Murilo-Callegari, if you look at the Runs list for your command, it should say "Command ran" if the command actually ran on your computer.

      If you're worried the screen still didn't lock even though your "lock screen" command ran, you could have your "lock screen" script also check whether the screen is locked, and send that information to the Runs list using the ~/.TRIGGERcmdData/result.sh script.

      Just run ~/.TRIGGERcmdData/result.sh from your "lock screen" script with a status message like "Locked" or "Unlocked" as the parameter when you run result.sh.

      You can also have Alexa speak the "Locked" or "Unlocked" result if you add {{result}} to your command's Voice Reply field and use one the Conversational Alexa skills.

      This article has more about that.

      posted in Mac
      RussR
      Russ

    Latest posts made by Russ

    • RE: How to run commands from Home Assistant

      @AZRushFan, in my experience I've been able to trigger the ON switch many times in a row even though the HA virtual switch status is ON. Are you saying you can't trigger the ON command if the switch is already ON?

      posted in Home Assistant
      RussR
      Russ
    • RE: New Computer Alexa doesnt work

      Thanks @Xander. I'm glad that worked.

      posted in Alexa
      RussR
      Russ
    • RE: New Computer Alexa doesnt work

      Sorry about this @Xander. Do you even see the devices in the Alexa device list? Also have you tried unlinking and relinking the TRIGGERcmd Smart Home skill?

      Please try changing one of your commands or make a new one with voice word banana. Alexa always recognizes it, and I doubt you're currently using that.

      Also please confirm you can run your commands from the website, so it's just the Alexa skill that isn't working.

      You said you copied everything over. What did you copy? If you copied your whole .TRIGGERcmdData folder the new computer should have taken the same computer ID and you wouldn't have to change anything, so I suspect you copied just your commands.json file over?

      posted in Alexa
      RussR
      Russ
    • RE: New Computer Alexa doesnt work

      @Xander, one thing to try is rename the computer because that should delete and recreate the Alexa devices. If that doesn't work, please try renaming one of your commands and see if that command works via Alexa.

      posted in Alexa
      RussR
      Russ
    • RE: How to create a trigger

      @gigaboy, thanks for sharing that link. I'm loving the fact that Google gave you that answer - to use TRIGGERcmd via IFTTT.

      If your server doesn't have a GUI, you'll have to edit your ~/.TRIGGERcmdData/commands.json file manually, using a text editor like vi (aka vim) or pico, nano etc.

      On Linux, your default ~/.TRIGGERcmdData/commands.json file includes the first 5 commands. I added the 6th command you could use to restart mysql, like Google says.

      [
        {"trigger":"Reboot","command":"shutdown -r","ground":"background","voice":"reboot","allowParams": "false"},
        {"trigger":"Gnome Editor","command":"gedit","ground":"foreground","voice":"notepad","allowParams": "false"},
        {"trigger":"Calculator","command":"gnome-calculator","ground":"foreground","voice":"calculator","allowParams": "false"},
        {"trigger":"yum update","command":"yum -y update","ground":"background","voice":"yum update","allowParams": "false"},
        {"trigger":"apt update","command":"apt-get -y update","ground":"background","voice":"update","allowParams": "false"},
        {
          "trigger": "Restart MySQL",
          "command": "sudo systemctl restart mysql",
          "offCommand": "",
          "ground": "background",
          "voice": "restart",
          "voiceReply": "",
          "allowParams": "false"
        }
      ]
      

      Notice I made "ground" = "background" because without a GUI, you probably installed the background agent (with installdaemon.sh) which runs the TRIGGERcmd agent in background mode as service.

      posted in General Discussion
      RussR
      Russ
    • RE: Ubuntu 22 - Installation throws permission denied, no prompt for token

      @gigaboy the errors you see here:

      Computer name for Local Home Assistant listener: null
      Error fetching computer name: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
          at Object.writeFile (node:fs:2311:5)
          at /usr/lib/triggercmdagent/resources/app/src/ha.js:120:10
          at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
        code: 'ERR_INVALID_ARG_TYPE'
      }
      

      Those errors are actually what I want to fix in the next version of the agent. The errors are related to the new Home Assistant integration. It errors like that on first run because it can't fetch the computer name. If you don't use Home Assistant you can ignore it, and if you do, just restart the agent.

      Anyway, to solve your problem, please try this:

      systemctl restart triggercmdagent
      

      Then check the status again with this:

      systemctl status triggercmdagent
      

      That will restart it and if it can find node 20, it should work. It just has to be above node 12, so 16 could work too.

      Let me know how goes please. Also, what method did you use the install nodejs? nvm or apt?

      posted in Linux
      RussR
      Russ
    • RE: Ubuntu 22 - Installation throws permission denied, no prompt for token

      @gigaboy, you're welcome. I found a separate problem I'd like to solve in a new version, but since then I also found the specific problem you ran into.

      I found the latest version of the triggercmd agent doesn't work with node version 12, and node version 12 gets installed by default on ubuntu 22 when you install nodejs. It worked fine for me on my ubuntu 24 because it installed node version 18 when I ran apt install nodejs.

      On your ubuntu 22 you could use nvm (node version manager) to install node version 16 (or greater) like this:

      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
      export NVM_DIR="$HOME/.nvm"
      [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
      [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
      nvm install 16
      

      In case it got bad data from a previous failed run, you should delete your ~/.TRIGGERcmdData folder like this:

      rm -rf ~/.TRIGGERcmdData
      

      Then run the agent again like this:

      node /usr/lib/triggercmdagent/resources/app/src/agent.js --console
      

      I like the flexibility of nvm, but here's another option for installing nodejs version 16:

      apt remove nodejs -y
      curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
      apt install -y nodejs
      

      Thank you for reporting your issue btw, and thank you for your patience.

      posted in Linux
      RussR
      Russ
    • RE: Ubuntu 22 - Installation throws permission denied, no prompt for token

      @gigaboy, looking into this now.

      EDIT: @gigaboy , I re-read your post. I see you're trying to use the agent on a server without X-Windows. I just tried that and I see I need to fix some things so give me some time to produce a new version.

      posted in Linux
      RussR
      Russ
    • RE: Ubuntu 22 - Installation throws permission denied, no prompt for token

      @gigaboy, I see your background agent is running with /root/.TRIGGERcmdData as its data directory, so please switch to root with sudo su - then run this command to enter your token:

      node /usr/lib/triggercmdagent/resources/app/src/agent.js --console
      

      Then restart the agent with this command:

      systemctl restart triggercmdagent
      

      Then, you can put your commands in your /root/.TRIGGERcmdData/commands.json file with ground=background.

      I'll have more time to run through the ubuntu instructions later today, but if you see this before then, please try the above and let me know how it goes.

      EDIT: I tried it on Ubuntu 24 and I got that same error but it worked fine.

      N: Download is performed unsandboxed as root as file '/home/gigaboy/triggercmdagent_1.0.1_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
      

      d592e631-c3cc-4693-ae64-33365f10516a-image.png

      posted in Linux
      RussR
      Russ
    • Download a Youtube video by passing the URL as a parameter

      I made this YouTube video to show how this works.

      Make sure to adjust the folder paths. I doubt you'll put your script in d:\appdev\triggercmd\youtube-dl or put your downloaded files in m:\videos\youtube like I did.

      Create a folder, open a cmd window in that folder, and type these to create the virtual environment with the yt_dlp python module:

      python3 -m venv myenv
      myenv\Scripts\activate.bat
      pip3 install yt_dlp
      

      youtube-dl.bat contents:

      setlocal enabledelayedexpansion
      
      :: This version of the script differs from the one in the Youtube video in that it handles any of these Youtube URL formats:
      :: https://www.youtube.com/watch?v=KqfRiPy5gFs
      :: https://youtu.be/KqfRiPy5gFs
      :: KqfRiPy5gFs
      
      :: Combine all arguments into a single string
      set "input="
      for %%A in (%*) do (
          set "input=!input! %%A"
      )
      
      :: Remove leading spaces
      set "input=%input:~1%"
      
      :: Check if the input contains "youtu.be" format and extract the video ID
      echo %input% | findstr /C:"youtu.be" >nul
      if not errorlevel 1 (
          set "id=%input:~17%"  :: Strip "https://youtu.be/"
      )
      
      :: Check if the input contains "youtube.com/watch?v=" format and extract the video ID
      if not defined id (
          echo %input% | findstr /C:"youtube.com/watch?v=" >nul
          if not errorlevel 1 (
              set "id=%input:~32%"  :: Strip "https://www.youtube.com/watch?v="
          )
      )
      
      :: If input is just the ID, no need for stripping
      if not defined id (
          set "id=%input%"
      )
      
      :: Ensure the ID is exactly 11 characters long
      set "id=%id:~0,11%"
      
      echo YouTube Video ID: %id%
      
      :: Go to the folder where I want the files to be created
      cd /d m:\videos\youtube
      
      :: Activate the Python virtual environment that has the yt_dlp module installed
      call d:\appdev\triggercmd\youtube-dl\myenv\Scripts\activate.bat
      
      :: Run the python script to download the video and metadata
      python d:\appdev\triggercmd\youtube-dl\youtube-dl.py %id%  > debug.log 2>&1
      

      youtube-dl.py contents:

      import yt_dlp
      import json, uuid, sys
      
      def download_video_metadata(video_url):
          ydl_opts = {
              'quiet': True,
              'skip_download': True,
              'force_generic_extractor': False,
          }
          
          with yt_dlp.YoutubeDL(ydl_opts) as ydl:
              try:
                  info_dict = ydl.extract_info(video_url, download=False)
                  return info_dict
              except Exception as e:
                  print(f"Error: {e}")
                  return None
      
      def download_video(video_url):
          ydl_opts = {
              'quiet': False,
              'outtmpl': '%(title)s.%(ext)s',
          }
          
          with yt_dlp.YoutubeDL(ydl_opts) as ydl:
              try:
                  ydl.download([video_url])
              except Exception as e:
                  print(f"Error: {e}")
      
      if __name__ == "__main__":
          if len(sys.argv) != 2:
              print("Usage: python3 youtube-dl.py <YouTube Video URL>")
              sys.exit(1)
      
          video_url = sys.argv[1]
          metadata = download_video_metadata(video_url)
          
          if metadata:
              print("Metadata:")
      
              filename=metadata.get('title', uuid.uuid4()) + ".json"
              with open(filename, "w") as file:
                  json.dump(metadata, file, indent=4)
      
              print("Downloading video...")
              download_video(video_url)
      

      Make sure you enable parameters:
      9f121796-6f1f-4241-9d2e-c0e83a221fc2-image.png

      If you want to create a panel, you can use this regex to accept any text: ^.*$
      8ac7a7eb-9e94-44e6-b259-93c72efd841c-image.png

      posted in Windows panel parameter python
      RussR
      Russ