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

    Adding Parameter to raspberry pi commands

    Scheduled Pinned Locked Moved Raspberry Pi
    5 Posts 3 Posters 2.2k Views 1 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            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 Offline
              Oskar Persson @Russ
              last edited by

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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post