Announcement

Collapse
No announcement yet.

XML HTTP RESTful API for HS3 - Discussion Thread

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

    #91
    Originally posted by RedTechie View Post
    Yeah, to be honest I have seen this issue as well with my Adobe Air/PHP based desktop widget. It seems like it starts lagging after sending a number of commands to Homeseer over a period of time. The one way I know of clearing the lag is restarting homeseer.

    I am not 100% sure at this point what is causing it so rather not point fingers. But I believe it is the backend HS API Controls I am calling. As all my script does is essentially wrap them in a pretty container that makes them accessible via simple URL calls. It could also be something with the embedded IIS server (web core) they are using in HS3, but then again I never really see the HS3 control panel lag....
    I looked into this a bit. I found a thing which seems to help. I created a schedule with windows scheduler which triggers a wget command which loads an empty(!) Event which does nothing. And also triggeres a virtual device which also does nothing. As far as I can see the lag is gone. Maybe a caching thing? I don't know but I hope this helps.

    Verstuurd vanaf mijn Nexus 5 met Tapatalk

    Comment


      #92
      Originally posted by Phaeton View Post
      I looked into this a bit. I found a thing which seems to help. I created a schedule with windows scheduler which triggers a wget command which loads an empty(!) Event which does nothing. And also triggeres a virtual device which also does nothing. As far as I can see the lag is gone. Maybe a caching thing? I don't know but I hope this helps.

      Verstuurd vanaf mijn Nexus 5 met Tapatalk
      Interesting... May I ask how often you have the wget scheduled to run? And have you noticed any side effects?

      Comment


        #93
        Originally posted by weaslyd View Post
        Interesting... May I ask how often you have the wget scheduled to run? And have you noticed any side effects?
        +1
        ________________________

        Dell Zino HD - HSPRo 2.x
        HSTouch - iPhone 3GS, 4S, iPad2 and iPad 3, 3xKindle Fire (Wall mounted)
        2 x Brultech ECM1240 with UltraECM
        USB UIRT
        Cooper Aspire Z-Wave Switches
        WGL800 w ACRF2 and 3xDS10a (Sump Level/Activity sensing)
        HM ST812-2 Flood Sensor
        HSM100 - Motion Detector with Light and Temperature
        2GIG Thermostat
        BLDSC - Alarm Plug-in
        BLUPS
        UltraLog (SQL2008)
        Jon00 Plugins
        Host XR3 BT and Jon00 BT Proximity
        Global Cache IP2IR
        Foscam FI8918W

        Comment


          #94
          Originally posted by RedTechie View Post
          Alright! Sorry for the long wait but the additions Gear added have now been released as version 1.2.0 ...
          Yep, this thing is sure useful. Very much appreciated!

          I send one of your commands from an iPad to get the status of a virtual device that tells if it's night or day. I can then control events for my home automation system (DemoPad).

          The only issue I had was that the replies of your aspx don't terminate with a Cr (\x0D).

          Details if you really want to know:
          My home automation app is not synchronous in its processing of TCP request/reply, so it offers a litteral matching scheme on all inbound messages.

          But it needs an escape sequence (default \x0D) to trigger it into looking for a match in the current TCP connection conversation. An end of buffer won't do it.
          Easy enough to fix in your code, but I now have a personalized version of your creation.

          If no one else has hit this issue, then just ignore this post. But if you find that a growing number of users are experiencing the same thing I have, then I'd like to propose this:
          Allow an additional last parameter to each function that, if not null, would indicate what is expected as a response terminator.

          Then each function would return what's there today concatenated with param2 or param3 depending on the function.
          If you implemented this, I believe this would be transparent to current users of your apsx.

          Comment


            #95
            Originally posted by mark_anderson_us View Post
            +1
            I now have the task scheduled once every three minutes. But only because I ran out of time because the baby started crying ;-)

            I wanted to add a minute to it every day until I notice it breaks down. But on the other hand, the task is light on resources and it works fine. I don't notice a glitch in my system and/or homeseer. When you disable logging for the event and device it won't fill you logs with useless lines.

            I keep it on for every three minutes for now


            Verstuurd vanaf mijn Nexus 5 met Tapatalk

            Comment


              #96
              [QUOTE=weaslyd;1132411]
              Originally posted by kideon View Post
              Is there a way to use this to toggle status with tasker? I know it can be used t trigger events and the solution there would be to create two events and then act based on present status then a third to trigger both but that's kind of kludgy.


              It appears you've moved past this question to a more complex solution, but I thought I'd share how I got device toggle working in Tasker.

              First off, my goal was to create toggles for my entertainment center and a few lights so they could be controlled by my new Android Wear smartwatch. I'm using Trigger on the watch to activate a Tasker task which sends an HTTP Get to the RESTful API to interface with HS3. It's working just as planned after 2-3 hours of tinkering.

              I've seen a few posts from people who are taking a more complex approach, but my programming skills being what they are (I generally learn as I go ) I just took a logical approach in Tasker.

              Since the latest version of the API adds the option to get current device status using (getdevicestatusvaluebyid), all I needed was an if-else to change the status. If the device is currently off, turn it on. Else turn it off. Easy, right? The problem I ran into was getting the device status into a variable. Tasker documentation claims the return value from an HTTP Get should be stored in HTTPR, but I was having trouble accessing it. So what I did to work around it was to store the return from the getdevicestatusvaluebyid call in an Output file. I then used READ FILE to transfer the value stored there into a variable (%Status in my case).

              This introduced another problem, as the data saved in the file includes a trailing carriage return. To fix this, I run Variable Split on the new variable. I then used %Status1 as the test in my If-Else. If %Status1 matches on then turn light off, else turn light on.

              As usual, I'm already coming up with ways to improve my work, but so far just the option of controlling things from my Android Wear device is pretty sweet. I hope this if this is no longer helpful to you, then at least someone else can avoid a bunch of trial and error, or having to reinvent the wheel.

              WeaslyD
              Pretty much exactly what I want to do, just not with Android wear just yet.. Currently have no clue what to do in tasker however

              Comment


                #97
                Any chance of this being ported to run in linux/raspberry pi? Just moved from windows to a Pi and it's a big part of my system.

                Comment


                  #98
                  I have been using this API to build a simple proxy from the Amazon Echo in order to control devices and run events by name. I just started adding a feature to get the status of a device and I found a problem with the GetDeviceStatusValueByName function.

                  Apparently not all devices return values from the "hs.CAPIGetControl(deviceRef)" call, meaning the foreach loop will not execute for those devices and the routine will return a blank.

                  What this means is that for lights it returns the status just fine, for things like motion sensors and thermostats, it returns blank. I don't know much about the HS API yet so I don't know what the deal is with CAPI control objects and child devices, but a very simple fix will at least allow the value to be returned.

                  Instead of initializing the device Value to an empty string, initialize it to the value.

                  string IsCAPI_Out = deviceValue.ToString();

                  Now if I can just figure out how to get the string "open" or "closed" and "motion" or "no motion" out of my various sensors. DeviceString seems to return a blank and as mentioned already those devices don't seem to have a CAPI control to get a label from.

                  For anyone who wants to fix their own copy of the script but isn't a programmer it is easy.

                  Search for this text, it should appear on line 715 of the file.
                  Code:
                  string GetDeviceStatusValueByName(string deviceName, string labelOrValue)
                  Four lines down you should see "string IsCAPI_Out =..."
                  Replace that line with this:
                  Code:
                  string IsCAPI_Out = deviceValue.ToString();

                  Comment


                    #99
                    RESTful API Script Questions

                    I have been working with the VERY COOL RESTful Script for just a few hours.
                    My goal is to use tasker on my android phone to submit the get queries.
                    For testing I am just using Chrome on a LAN computer.

                    I can submit a string to the speaker client. - OK
                    I can trigger an event in HS3 - OK
                    I can set an INSTEON device by name ON/OFF/TOGGLE - OK

                    I have a GlobalCache IR device
                    Floor = GlobalCache IR
                    Room = UltraGCIR3 Plugin
                    Device name = Computer Room AV IR Module 2:2
                    Command = POWER TOGGLE

                    PHP Code:
                    http://nnn.nnn.nnn.nnn:81/Homeseer_REST_API.aspx?function=setdevicebyname&param1=GlobalCache%20IR%20UltraGCIR3%20Plugin%20Computer%20Room%20AV%20IR%20Module%202%3A2&param2=POWER%20TOGGLE 
                    Does not work.
                    What is really weird is this URL triggers a download of the script???? in chrome.
                    Not sure if I am doing something wrong or if the script does not work with
                    GlobalCache IR devices.

                    I have a virtual device
                    Floor = General
                    Room = General
                    Device name = Car Home
                    2 Controls = Car is Away, Car is Home

                    PHP Code:
                    http://nnn.nnn.nnn.nnn:81/Homeseer_REST_API.aspx?function=setdevicebyname&param1=General%20General%20Car%20Home&param2=Car%20is%20Away 
                    This controls the device but returns ALL_Failed in the browser


                    PHP Code:
                    http://nnn.nnn.nnn.nnn:81/Homeseer_REST_API.aspx?function=setdevicebyname&param1=General%20General%20Car%20Home&param2=Car%20is%20Home 
                    This controls the device and returns All_Success in the browser

                    Can anyone shed some light on this problem?

                    Thanks
                    Tom

                    Comment


                      Error on Linux

                      Hi,

                      I've used this PI on my Win7/HomeSeer system and I'm in the process of migrating to Ubuntu 14.04.2 LTS x64. Is this plugin suppose to work under Linux? I'm getting the following error:

                      System.Web.Compilation.CompilationException
                      : Unhandled Exception:
                      Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.
                      Details: : Unhandled Exception:
                      Error origin: Compiler
                      Error source file: /HomeSeer_REST_API.aspx
                      Exception stack trace:
                      at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] in <filename unknown>:0
                      at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0
                      at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
                      at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0


                      Thanks for your help!

                      Comment


                        The RESTful API development might be orphaned; the creator, RedTechie, hasn't been active on these boards since September 2014.

                        Comment


                          hmatos - I've experienced the same issue, and it seems to be that the web server running for HS3 on Linux doesn't want to compile C# code for ASP, though VB works fine. Did you ever have any luck with this?

                          Comment


                            The problems you describe below are due to buggy code.
                            I'm doing a major refresh on this and will publish it in a few days.

                            The code that I'll be posting will have much improved error handling, formatting, and major corrections to CAPI handling...



                            Originally posted by Seer1001 View Post
                            I have been working with the VERY COOL RESTful Script for just a few hours.
                            My goal is to use tasker on my android phone to submit the get queries.
                            For testing I am just using Chrome on a LAN computer.

                            I can submit a string to the speaker client. - OK
                            I can trigger an event in HS3 - OK
                            I can set an INSTEON device by name ON/OFF/TOGGLE - OK

                            I have a GlobalCache IR device
                            Floor = GlobalCache IR
                            Room = UltraGCIR3 Plugin
                            Device name = Computer Room AV IR Module 2:2
                            Command = POWER TOGGLE

                            PHP Code:
                            http://nnn.nnn.nnn.nnn:81/Homeseer_REST_API.aspx?function=setdevicebyname&param1=GlobalCache%20IR%20UltraGCIR3%20Plugin%20Computer%20Room%20AV%20IR%20Module%202%3A2&param2=POWER%20TOGGLE 
                            Does not work.
                            What is really weird is this URL triggers a download of the script???? in chrome.
                            Not sure if I am doing something wrong or if the script does not work with
                            GlobalCache IR devices.

                            I have a virtual device
                            Floor = General
                            Room = General
                            Device name = Car Home
                            2 Controls = Car is Away, Car is Home

                            PHP Code:
                            http://nnn.nnn.nnn.nnn:81/Homeseer_REST_API.aspx?function=setdevicebyname&param1=General%20General%20Car%20Home&param2=Car%20is%20Away 
                            This controls the device but returns ALL_Failed in the browser


                            PHP Code:
                            http://nnn.nnn.nnn.nnn:81/Homeseer_REST_API.aspx?function=setdevicebyname&param1=General%20General%20Car%20Home&param2=Car%20is%20Home 
                            This controls the device and returns All_Success in the browser

                            Can anyone shed some light on this problem?

                            Thanks
                            Tom

                            Comment


                              Hey folks,
                              I feel really dumb posting this, but I can't seem to get any of this to work on win10 for me.

                              After running any command pointed at the aspx file, I get this response:

                              Error Processing ASP.NET page: Object reference not set to an instance of an object.

                              I'm sure it's something simple. Do I need to install something else on my computer to get this to work?

                              Thanks

                              Comment


                                Are you running HS3 as a service? If so, this is the cause.

                                I think I read somewhere that people have got ASPX pages to work as a service if you install HS3 into a drive root directory (i.e C:\HS3) rather than its default (Program Files (x86)\Homeseer HS3).
                                Jon

                                Comment

                                Working...
                                X