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

Adding Parameter to raspberry pi commands

Raspberry Pi
3
5
1.4k
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.
  • J
    js
    last edited by js May 8, 2019, 7:14 PM May 8, 2019, 2:09 AM

    Re: Raspberry Pi setup

    I am trying to turn on/off monitor connected to raspberry pi using one command by passing two different parameter. Could you please help me with the command

    R 1 Reply Last reply May 8, 2019, 10:12 PM Reply Quote 0
    • R
      Russ @js
      last edited by May 8, 2019, 10:12 PM

      @js, can you post the commands you're using to turn your monitor on and off?

      You can use a script like this to handle the on and off parameters:

      #!/bin/bash
      
      if [ "$1" = "on" ] ; then
        echo Turning it on
      fi
      
      if [ "$1" = "off" ] ; then
        echo Turning it off
      fi
      

      Russell VanderMey

      1 Reply Last reply Reply Quote 0
      • J
        js
        last edited by May 31, 2019, 2:37 PM

        Sorry for the delay. Please find the commands listed below

        sudo cat /root/.TRIGGERcmdData/commands.json
        [
        {"trigger":"Monitor ON","command":"vcgencmd display_power 1","ground":"background","voice":"Monitor ON","allowParams": "false"},
        {"trigger":"Monitor OFF","command":"vcgencmd display_power 0","ground":"background","voice":"Monitor OFF","allowParams": "false"}
        ]

        R 1 Reply Last reply May 31, 2019, 10:01 PM Reply Quote 0
        • R
          Russ @js
          last edited by May 31, 2019, 10:01 PM

          Ok @js, you could change your commands.json to this:

          [
            {"trigger":"Monitor","command":"/root/monitor.sh","ground":"background","voice":"Monitor","allowParams": "true"}
          ]
          

          And put this in your /root/monitor.sh script:

          #!/bin/bash
          
          if [ "$1" = "on" ] ; then
            echo Turning it on
            vcgencmd display_power 1
          fi
          
          if [ "$1" = "off" ] ; then
            echo Turning it off
            vcgencmd display_power 0
          fi
          

          And say this to Alexa or Google Assistant:

          ask TRIGGERcmd to run monitor with parameter on
          

          Or use the TRIGGERcmd Smart Home Alexa skill or the SmartThings integration with Google Assistant, and say this:

          turn on monitor
          

          Russell VanderMey

          O 1 Reply Last reply Nov 3, 2022, 9:54 AM Reply Quote 1
          • T tuicemen moved this topic from Instructions on Jan 30, 2022, 7:56 PM
          • O
            Oskar Persson @Russ
            last edited by Nov 3, 2022, 9:54 AM

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • First post
              Last post