Announcement

Collapse
No announcement yet.

Passing Parameters to Scripts...

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

    Passing Parameters to Scripts...

    How can I setup a new Action “Run Script with Parameters” that would prompt for a script file name and parameters? Currently it just prompts for a script file name.

    I’d like to be able to call a common script file with different parameters based on Event context...

    Also if using JScript is there a way to import external .js files?
    Last edited by virtualadam; July 12, 2009, 02:39 PM.

    #2
    Originally posted by virtualadam View Post
    How can I setup a new Action “Run Script with Parameters” that would prompt for a script file name and parameters? Currently it just prompts for a script file name.

    I’d like to be able to call a common script file with different parameters based on Event context...

    Also if using JScript is there a way to import external .js files?
    on the action tab of an event, after you select the 'run script' action, click the 'switch to advance view' btn. you will get the 'optional paramters' field where you can enter the "sub name", "parameters" for the script file you select in the "existing script" field.


    you can test this manually by doing the following from the "immediate script cmd" on the "control" page:

    hs.runex "myscriptfilename.vbs", "mysubname", "my parameter value"

    parameters can only be passed as a string and then must be parsed, etc as necessary

    can't answer the .js question
    Mark

    HS3 Pro 4.2.19.5
    Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
    Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
    Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

    Comment


      #3
      Perfect - just what I was looking for. Thanks.

      Comment


        #4
        Seems that it only accepts one parameter? I ended up creating an 'execute' function that parses the one parameter string and calls the requested function based on a parameter format "function,param 1, param2, etc" to handle multiple parameters...

        Works, but wondering if there is another recommended way to do this?

        Comment


          #5
          Originally posted by virtualadam View Post
          Seems that it only accepts one parameter? I ended up creating an 'execute' function that parses the one parameter string and calls the requested function based on a parameter format "function,param 1, param2, etc" to handle multiple parameters...

          Works, but wondering if there is another recommended way to do this?
          This is the proper way of doing it. Pass a delimeted set and parse the params.
          💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

          Comment


            #6
            Originally posted by virtualadam View Post
            Seems that it only accepts one parameter? I ended up creating an 'execute' function that parses the one parameter string and calls the requested function based on a parameter format "function,param 1, param2, etc" to handle multiple parameters...

            Works, but wondering if there is another recommended way to do this?
            i don't think you need the extra 'execute' function. just enter the function you want with a parameter value that looks like the following in the event setup in the Optional parameters field

            "functionname","parm1,parm2"

            and then use either the hs.StringItem or the .net string.split method in 'functionname' to parse the string into pieces.
            Mark

            HS3 Pro 4.2.19.5
            Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
            Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
            Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

            Comment


              #7
              This may help: http://board.homeseer.com/showthread.php?t=128189
              Jon

              Comment


                #8
                Has anyone else had a problem using a comma?

                Has anyone else had a problem using a comma as a delimiter? I ran into some strange behavior the other day and the problem went away when I changed from using a "," to using a ":". Haven't got back to trying it again but this thread made me think of it.

                Ken
                "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

                Comment


                  #9
                  In older versions of Homeseer, the use of a comma as a delimiter does not work, however the latest versions seem to have rectified this issue.
                  Jon

                  Comment

                  Working...
                  X