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

      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

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

        @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

          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"}
          ]

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

            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

            Oskar PerssonO 1 Reply Last reply Reply Quote 1
            • tuicemenT tuicemen moved this topic from Instructions on
            • Oskar PerssonO
              Oskar Persson @Russ
              last edited by

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