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

Is it possible to have more then one parameter?

Raspberry Pi
4
6
942
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.
  • T
    tuicemen
    last edited by Jan 6, 2022, 9:25 PM

    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

    R B 2 Replies Last reply Jan 6, 2022, 10:49 PM Reply Quote 0
    • R
      Russ @tuicemen
      last edited by Russ Jan 6, 2022, 10:50 PM Jan 6, 2022, 10:49 PM

      @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

      T 1 Reply Last reply Jan 7, 2022, 11:48 AM Reply Quote 0
      • T
        tuicemen @Russ
        last edited by Jan 7, 2022, 11:48 AM

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

        R 1 Reply Last reply Jan 7, 2022, 1:07 PM Reply Quote 0
        • R
          Russ @tuicemen
          last edited by Jan 7, 2022, 1:07 PM

          @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

          T 1 Reply Last reply Jan 7, 2022, 3:34 PM Reply Quote 0
          • T
            tuicemen @Russ
            last edited by Jan 7, 2022, 3:34 PM

            @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
            • B
              boblewis @tuicemen
              last edited by May 23, 2024, 11:49 AM

              @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