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

    Is it possible to have more then one parameter?

    Raspberry Pi
    4
    6
    806
    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.
    • tuicemenT
      tuicemen
      last edited by

      I'm playing with x10 on a Raspi using HomeGenie
      x10 has a possible 256 addresses that's a lot of bash scripts just for On_Off

      Is it possible to add house code (A-P) as an additional paramiter and unit codes (1-16) as another?
      the command to turn on a device at house code A unit code 4 would look like this:
      curl http://url&port/api/HomeAutomation.X10/A4/Control.On

      RussR boblewisB 2 Replies Last reply Reply Quote 0
      • RussR
        Russ @tuicemen
        last edited by Russ

        @tuicemen, you can use $1, $2, and $3 as placeholders for multiple parameters to your script, like this:

        russ@RussHP:~$ ./x10.sh A 4 on
        curl http://url:port/api/HomeAutomation.X10/A4/Control.on
        russ@RussHP:~$ cat ./x10.sh
        #!/bin/bash
        echo curl http://url:port/api/HomeAutomation.X10/$1$2/Control.$3
        

        You'd want to remove echo from the script. I just included that so it would show you the substitutions in the curl command.

        Russell VanderMey

        tuicemenT 1 Reply Last reply Reply Quote 0
        • tuicemenT
          tuicemen @Russ
          last edited by

          @russ thanks, creating the bash file was no problem. I had that working but think the commands.json file is where I've messed up.

          Since HomeGenie can handle several different protocols, I've been rethinking what each parameter holds. I may be able to get one simple bash file to handle all protocols I use.
          Just need to play with the commands.json file.

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

            @tuicemen , if you show me your commands.json I can probably spot the problem. It's usually that you need to escape some characters with a backslash.

            One way to do it is to use the GUI editor on another computer and copy the json text over.

            Russell VanderMey

            tuicemenT 1 Reply Last reply Reply Quote 0
            • tuicemenT
              tuicemen @Russ
              last edited by

              @russ Thanks, I found my error, the line in the commands.json file was correct.
              I was putting in the wrong X10 address for my test thus it was turning on/off a light in the basement not my test light.

              1 Reply Last reply Reply Quote 1
              • boblewisB
                boblewis @tuicemen
                last edited by

                @tuicemen

                You can add house code (A-P) and unit codes (1-16) as parameters in your bash scripts.

                #!/bin/bash
                house_code=$1
                unit_code=$2
                action=$3
                curl "http://url:port/api/HomeAutomation.X10/${house_code}${unit_code}/Control.${action}"
                Run it like this:
                ./control_x10.sh A 4 On

                This way, you only need one script.

                Thank you
                boblewis

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post