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

Posts made by Russ
-
RE: How to run commands from Home Assistant
-
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?
-
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.
-
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.
-
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?
-
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.
-
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.
-
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)
-
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:
If you want to create a panel, you can use this regex to accept any text: ^.*$
-
RE: Command ran with error code 1 trying shutdown command
@vitormbn , if you run the same command from a CMD window does it work? Error code 1 means it's running the command but it's failing. Ideally it will fail in the same way so you can see the error. One possible reason for the failure might be you don't have admin access on your machine.
-
RE: TriggerCMD throws an Application Error upon computer shutdown.
@Paul-Kelly, please upgrade to the new version (1.0.46) I just published. I wasn't able to reproduce the error, but it's an intermittent problem, so I'm not sure this will fix it. Please let me know if you see it again after you upgrade.
-
RE: Cant Get Background Services to Work anymore
I replied to you here, but basically I broke the background service in version 1.0.45. I just need to upgrade the node version and update the agent. I'll do that today. Stay tuned.
EDIT: Please upgrade to version 1.0.46. It should fix the windows background service. Sorry about the bug.
-
RE: Background service
@Tony-Seaback, I replied to you here, but basically I broke the background service. I just need to upgrade the node version and update the agent. I'll do that today. Stay tuned.
EDIT: Please upgrade to version 1.0.46. It should fix the windows background service. Sorry about the bug.
-
RE: background agent commands not syncing or service not starting please assist. PLEASE ! thank you
@Tony-Seaback, I see the problem. I broke the background service in this latest version 1.0.45. I'll produce a new version today and get back to you.
EDIT: Please upgrade to version 1.0.46. It should fix the windows background service. Sorry about the bug.
-
RE: Issue with TriggerCMD Commands Not Updating on Website
@Tony-Seaback, I see from your other posts you're using the background service. I assume the foreground service is sync'ing foreground commands just fine?
I just found out the background service is broken on Windows version 1.0.45. I'm working on the fix now.
EDIT: Please upgrade to version 1.0.46. It should fix the windows background service. Sorry about the bug.
-
RE: TriggerCMD throws an Application Error upon computer shutdown.
@Paul-Kelly , thanks for reporting it. I'll look into it this weekend. Are you running the latest version?
-
RE: Issue Connecting Second PC to Alexa for Automatic Shutdown
@theotherclub, your second computer needs to have a "Voice Name" before Alexa will create devices for each of that computer's triggers.
Your first computer doesn't need a Voice Name because it's your default computer by default.
This page in the documentation explains further:
https://docs.triggercmd.com/#/./SmartHomeSwitches -
RE: after format my pc, i can't use trigger cmd, it say that i need to subscribe for add a new computer
@Mark-Hollis, your commands are not stored in the cloud. They're only stored on your computer, so if you don't have a backup of your commands.json file, you'll need to recreate them. One Windows you can find your commands.json file in this folder:
c:\Users\(your user)\.TRIGGERcmdData
If you're not subscribed, you'll need to delete your current computer before you can create another one.
-
RE: Closing Apps created in Edge / Chrome Browsers
@JRSF-Home , this worked for me to open and close the Trigger CMD PWA:
Command:
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge_proxy.exe" --profile-directory=Default --app-id=ehccgonefendpahldcmdgdmbkpbdmhbg --app-url=https://app.triggercmd.com/ --app-launch-source=4
Off Command:
taskkill /FI "WINDOWTITLE eq Trigger CMD"
I got that "Trigger CMD" text from the title of the PWA window.