Announcement

Collapse
No announcement yet.

Linux, Bash and event values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Linux, Bash and event values

    hi..

    Quick question.. how can i pass a device value to a shell script ?

    I have no problem running script with parameters, but how can i get the value to be one of them ?

    Im running the script as "Run another program or process" with Bash as the program and script (.sh) with parameters as command parameters.
    Last edited by levring; January 11, 2017, 03:17 PM.

    #2
    Use replacement variables as described in the following link.

    http://homeseer.com/support/homeseer..._variables.htm

    Comment


      #3
      Originally posted by lveatch View Post
      Use replacement variables as described in the following link.

      http://homeseer.com/support/homeseer..._variables.htm
      Thanks for the input..
      It works great while sending an email, but I cant get it to work then passing the variable to a script.

      Requesting program: "/bin/bash"
      With parameter: "/home/pi/HomeSeer/scripts/beoplay.sh 192.168.2.98 volume $$DVR:128:"

      Any idea why the variable is not being replaced ?

      Comment


        #4
        For those returning to this thread..

        As said in previous post the replacement variables are not supported in running program or process. But found a workaround here by modifying the speak script and using the speak functionality instead.
        https://forums.homeseer.com/showpost...39&postcount=8

        Comment


          #5
          I was just going to ask will check the other thread

          Comment


            #6
            Any update on this?

            anyone tried to get the value with json homeseer api and put in into a variable then put this variable in a curl command?

            Comment


              #7
              not with the curl command but with a Perl script that I wrote using my own Perl module implementing the JSON API. Typically used from outside of HS to get info from HS.

              Code:
              ./getHsDevice.pl -r 1005 -a name,value
              Todays Rain Amount,0.02
              
              ./getHsDevice.pl -f 'Todays Rain Amount'  -a ref,name,value
              $VAR1 = 1005;
              1005,Todays Rain Amount,0.02

              It can be called several ways -r <refId>, -f 'search string' (not sure if this is fully working). -a comma separated JSON attributes.

              Before I moved my graphing to Influx / Grafana, I executed Perl scripts from HS passing in the reference ID. Used the same Perl module to get the value.

              Code:
              Launch /usr/bin/perl With Parameters: /usr/HomeSeer/veatch/scripts/logTempature.pl -deviceCode 122 -s masterBR

              Comment


                #8
                thanks !!

                with a lot a searching on the net ( not a programmer) i have been able to get it working :


                Code:
                #!/bin/bash
                #
                
                a=$(curl --max-time 5.0 'http://127.0.0.1:PORT/JSON?request=getstatus&ref=1746' | jq -r '.Devices[0] .value');b=$( echo $a *2.54 | bc) ; c=$( echo $b | awk '{print ($0-int($0)<0.499)?int($0):int($0)+1}'); curl --max-time 5.0 -X PUT -H "Content-Type: application/json" -d '{"on": true,"bri": '$c',"transitiontime": 1}' "http://127.0.0.1:port/api/xxxxxxxxxxxxxx/groups/1/action"

                Comment

                Working...
                X