Announcement

Collapse
No announcement yet.

Running script through JSON call?

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

    Running script through JSON call?

    I have been searching around and can't seem to find the answer for this, if it is even possible. Is it possible to make a JSON call to an HS3 server and run a script and pass it parameters? If so, what is the syntax? Thanks

    #2
    As far as I'm aware, no call exists.
    Jon

    Comment


      #3
      I couldn't find a way to pass parameters, so I created virtual devices on the HS3 machine to hold each parameter and updated the devices with JSON calls, then another JSON call to run an event that runs the script. The script on the HS3 machine gets the parameters from the virtual devices. Here's the JSON call to run the event:

      Code:
      Dim GetUrlHost as string = "http://192.168.143.200"   'I.P. address of remote server
      Dim GetUrlPort as string = "80"    'Port of remote webserver
      Dim GetUrlArg As String
      Dim page As String
      
      ' setup GetUrl variable to run remote event
      
      GetUrlArg = "/JSON?request=runevent&group=Telephone&name=Phone_CIDShowAnnounce"
      
      page = hs.GetURL(GetUrlHost, GetUrlArg, True, GetUrlPort)
      Fred

      HomeSeer Pro 3.0.0.548, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

      Comment


        #4
        Waking up an old thread I later discovered this

        https://github.com/TheInsomniac/homeseer-jsonapi

        I am using it to access my HS2 installation. I wrote a lot of custom scripts to switch my whole house audio system in HS2 years ago and they just work - so have never pulled them over the HS3 or HS4. I was able to use this modify this to setup HS2 to accept commands through JSON for running scripts.

        So I am now hacking away at this approach to get a simple script call going through HS3 with JSON. It is definitely trial and error but I am hoping this will work.

        Comment


          #5
          Originally posted by simonmason View Post
          Waking up an old thread I later discovered this

          https://github.com/TheInsomniac/homeseer-jsonapi

          I am using it to access my HS2 installation. I wrote a lot of custom scripts to switch my whole house audio system in HS2 years ago and they just work - so have never pulled them over the HS3 or HS4. I was able to use this modify this to setup HS2 to accept commands through JSON for running scripts.

          So I am now hacking away at this approach to get a simple script call going through HS3 with JSON. It is definitely trial and error but I am hoping this will work.
          I think you run HS on Windows.

          If so, you can easily run a script via an ASP page. It has no JSON response but you can pass parameters.

          Example Runscript.asp (place in your html directory).

          Code:
          <!DOCTYPE html>
          <html>
          <body>
          <%
          Dim Name, Func, Parms
          Name = Request.QueryString("name")
          Func = Request.QueryString("func")
          Parms = Request.QueryString("parms")
          hs.Runscriptfunc Name,Func,Parms,False,False
          %>
          </body>
          </html>
          To call, use:

          http://<homeseer IP : port>/Runscript.asp?name=myscriptname.vb&func=Main&parms=hello
          Jon

          Comment


            #6
            Thanks pal. Worked like a charm.

            Comment


              #7
              jon00

              Any thoughts on how to run this command through runscript.asp?

              192.168.2.70:86/Runscript.asp?name=Jon00RCCNMHS3.vben&func=Main&parms=8||run ||firefox.exe||https://sharptools.io/dashboard/view/<KEY>?kiosk=true -kiosk

              I tried escaping the spaces and it still didn't work:

              192.168.2.70:86/Runscript.asp?name=Jon00RCCNMHS3.vben&func=Main&parms=8||run ||C:\Program%20Files\Mozilla%20Firefox\firefox.exe||https://sharptools.io/dashboard/view/<KEY>?kiosk=true%20-kiosk

              Thanks.

              Comment


                #8
                The issue is you are trying to send another URL in the parms and I suspect the second ? is causing an issue.

                Maybe easier just to add a line to runscript.asp

                If Parms = "Preset1" Then Parms = "8||run ||C:\Program%20Files\Mozilla%20Firefox\firefox.exe||https://sharptools.io/dashboard/view/<KEY>?kiosk=true%20-kiosk"

                Then just send "Preset1" as the parms entry in the url.
                Jon

                Comment


                  #9
                  Thanks. I will play around with that.

                  Comment


                    #10
                    @simonmason​, I see you were trying to get "Sharptools" to work with HS any success?
                    Computer: CUK Intel NUC7i7BNH
                    Op System: Windows10 Pro - Work Station
                    HS Version: HS4 Pro Edition 4.2.19.0

                    Plug-Ins: AK Weather 4.0.5.25,APCUPSD 3.3.2.3,BLBackup 2.0.63.0,BLEditor 2.0.11.0,BLGData 3.0.55.0,BLOccupied 2.0.28.0,BLShutdown 1.0.6.0,Blue-Iris 3.1.3.33206,Device History 3.2.0.2,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,iRobot 5.22.41.1,JowiHue 4.0.8.7,Nest 3.0.0.34,NetCam Plugin 1.0.0.5,PHLocation2 3.0.0.64,Pushover 4.0.10.0,Random 3.0.0.2,Restart 1.0.0.7,Ring 1.0.0.9,SDJ-Health 3.1.1.3,Sonos 3.1.0.59,Sonos4 4.0.1.12,UltraCID3 3.0.6681.34300,UltraMon3 3.0.6554.33094,UltraNetCam3 3.0.6413.20219,Unifi 4.0.32.0,Zigbee 4.0.11.0,Z-Wave 4.0.3.0, and Jon00 scripts.

                    Comment


                      #11
                      HI MNB. I do use Sharptools on all of my touchscreens. I started some time ago using JSON calls but then started using Hubitat as it has a direct plug-in. Now I do most of my processing there.

                      Comment

                      Working...
                      X