Announcement

Collapse
No announcement yet.

Problem with HAI scripting

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

  • Problem with HAI scripting

    Hi;

    I am using the following script (run every 2 minutes) to populate some virtual devices so that MCStemperature can log the data.

    Every now and then (6-12 times a day) the values that get populated into the devices are like 9999.99 or 99.9.

    I have monitored the system and confirmed the wrong data get's populated into the devices as opposed to MCSTemp reading it wrong

    As you can tell I am not a programmer but I modified the HAI_System_Ceck.txt for my use. Maybe it is not done properly?
    I have tryed hs.devicevaluechange also and ended up with the same results

    Any help would appreciated!


    AndyM

    Sub Main()

    Dim iStatus

    iStatus = 999
    iStatus = hs.plugin("HAI_System").InterfaceStatus
    if iStatus = 0 then

    hs.setdevicestring "w30", hs.plugin("HAI_System").HAI_WhatIsTemp(1)
    hs.setdevicestring "w31", hs.plugin("HAI_System").HAI_WhatIsTemp(2)
    hs.setdevicestring "w32", hs.plugin("HAI_System").GetAuxTemp_Temp(14)
    hs.setdevicestring "w33", hs.plugin("HAI_System").GetAuxTemp_Temp(15)
    hs.setdevicestring "w34", hs.plugin("HAI_System").GetAuxTemp_Temp(13)

    hs.setdevicevalue "w30", now
    hs.setdevicevalue "w31", now
    hs.setdevicevalue "w32", now
    hs.setdevicevalue "w33", now
    hs.setdevicevalue "w34", now

    else

    WriteLog "HAI CHECK","Interface Status is " & CStr(iStatus)
    end if

    End Sub

  • #2
    I chnaged the script to write to the HS log to if/when if the values returned by the plug-in are wrong:

    Sub Main()

    hs.setdevicestring "w30", hs.plugin("HAI_System").HAI_WhatIsTemp(1)
    hs.setdevicelastchange "w30", now
    hs.WriteLog "HAI Update","Upstairs Temp: " & hs.devicestring ("w30")
    hs.setdevicestring "w31", hs.plugin("HAI_System").HAI_WhatIsTemp(2)
    hs.setdevicelastchange "w31", now
    hs.WriteLog "HAI Update","Downstairs Temp: " & hs.devicestring ("w31")
    hs.setdevicestring "w32", hs.plugin("HAI_System").GetAuxTemp_Temp(14)
    hs.setdevicelastchange "w32", now
    hs.WriteLog "HAI Update","Upper Deck Temp: " & hs.devicestring ("w32")
    hs.setdevicestring "w33", hs.plugin("HAI_System").GetAuxTemp_Temp(15)
    hs.setdevicelastchange "w33", now
    hs.WriteLog "HAI Update","Upper Deck Humidity: " & hs.devicestring ("w33")
    hs.setdevicestring "w34", hs.plugin("HAI_System").GetAuxTemp_Temp(13)
    hs.setdevicelastchange "w34", now
    hs.WriteLog "HAI Update","Lake Water Temp: " & hs.devicestring ("w34")

    End Sub

    Comment


    • #3
      Still having issue:

      Using:

      Sub Main()

      hs.setdevicestring "w30", hs.plugin("HAI_System").HAI_WhatIsTemp(1)
      hs.setdevicelastchange "w30", now
      hs.WriteLog "HAI Update","Upstairs Temp: " & hs.devicestring ("w30")
      hs.setdevicestring "w31", hs.plugin("HAI_System").HAI_WhatIsTemp(2)
      hs.setdevicelastchange "w31", now
      hs.WriteLog "HAI Update","Downstairs Temp: " & hs.devicestring ("w31")
      hs.setdevicestring "w32", hs.plugin("HAI_System").GetAuxTemp_Temp(14)
      hs.setdevicelastchange "w32", now
      hs.WriteLog "HAI Update","Upper Deck Temp: " & hs.devicestring ("w32")
      hs.setdevicestring "w33", hs.plugin("HAI_System").GetAuxTemp_Temp(15)
      hs.setdevicelastchange "w33", now
      hs.WriteLog "HAI Update","Upper Deck Humidity: " & hs.devicestring ("w33")
      hs.setdevicestring "w34", hs.plugin("HAI_System").GetAuxTemp_Temp(13)
      hs.setdevicelastchange "w34", now
      hs.WriteLog "HAI Update","Lake Water Temp: " & hs.devicestring ("w34")

      End Sub

      Getting:
      Attached Files

      Comment


      • #4
        Try encasing your script commands within a command that checks the status of the interface. Depending upon the version of firmware you have in the HAI system and the version of the plug-in you have, it may be that the link between the HAI and HomeSeer is periodically resetting or timing out. There is a command that returns the status of the Interface and when the interface is having communication issues, you will get return values such as what you are seeing.

        Often those values are due to the HAI system not responding within an alotted timeframe, and since I don't want the script engine hung waiting, the plug-in returns those values and exits.

        If this persists and checking the interface status does not help, then open up a helpdesk ticket and include the firmware version you have (it is shown when HomeSeer starts), HAI model, and plug-in version and I'll see if I can come up with a solution.

        Regards,

        Rick Tinker
        HomeSeer Technologies

        Regards,

        Rick Tinker (a.k.a. "Tink")

        Comment


        • #5
          I have essentially the same problem. Has a solution to this problem been made? And if so, what is the solution?

          Comment


          • #6
            I've seen this as well with my HMS 1050 system and the HAI plugin.

            I have a script that announces the temperature of our enclosed back porch when we get home. About every 5th or 6th time it announces that the back porch temperature is 10,000 degree's. I'm sure it's getting the 9999.99 but I use the vbs round command to round the temperature.

            When I happens my wife smiles at me and gives me the 'yea sure, you're a computer wizard' look.

            George

            Comment


            • #7
              Currently and from the beginning when the plug-in was originally written, there are two types of polling events going on with the plug-in in addition to ad-hoc requests such as those made by scripts. The way the plug-in works today, some of those ad-hoc requests are made directly to the panel instead of using the information in memory. e.g. When zone 1 changes, the status is saved in memory in the plug-in, but a request to get the Zone 1 status forces it to get the latest information. (It does not really do that but that is an example of what I am talking about.) Sometimes, a poll has just taken place and so the response to the poll comes in when the plug-in was expecting a response to its recent ad-hoc query, and this confuses the heck out of things because it was not written to get things out of order.

              What I am working on in my copious spare time is a rather dramatic rewrite of the communications interface. I did a similar major change from what the plug-in originally did a while ago and that is when I discovered this design limitation, and so this time I want to fix it for good.

              What I am probably going to do is to change the data coming from the panel to be interrupt driven - e.g. When a response comes in, the plug-in will handle it whatever type that it is rather than sitting there and waiting for a response right after it sends the command. On the plus side, I will remove any issues caused by data coming from the panel in an unexpected order. On the minus side, all information returned by the plug-in will have to be from memory rather than realtime. If HAI did not make me have to poll, things might be quite different... Anyway, an example of this is with this scenario: You click on the link in a web page that perhaps changes an output from off to on, and when the page refreshes it sometimes displays the new status but often it displays the old one. Refreshing the page, even if it is right away, will then display the right status because by then the plug-in has received the ack from the panel that the command was completed and the plug-in has then received the updated status directly from the panel. After I make this change, you will NEVER get the most recent status when the page refreshes unless I artifically delay the refresh/redraw of the web page. It will always return the information currently in memory and even though it only takes a second or two to get an update from the panel, the page will be redrawn before the data comes back from the panel.

              So... finding ways to deal with these issues is what I am thinking about as I undertake this rewrite. I also have thermostat plug-ins, and support on 3 or 4 other plug-ins that I am working on so I would not hold my breath on getting a due date from me.

              I am providing all of this information just to let you know that I am aware of these issues being an HAI user myself, and that I do have plans to find some way of addressing them.


              Regards,

              Rick Tinker
              HomeSeer Technologies

              Regards,

              Rick Tinker (a.k.a. "Tink")

              Comment


              • #8
                While at CES, you need to get a (ahem) "professional" lady to visit Jay McLellan (president of HAI) and threaten to release the photos if he doesn't get a non-polling protocol out. Matter of fact, at the same time get a gentleman of the Tony Soprano type to take care of Scott D.

                My system is described in my profile.
                My system is described in my profile.

                Comment


                • #9
                  I have had the same problem, so I wrote a script that saves the temperature to an INI file, then every time I run my temp script it checks to see if the new temperature is out of range. If it is out of range, it rechecks every second for 5 seconds. If it still is out of range then it returns the temperature I stores in the INI file from the last “good” temperature check.

                  This has reduced my temp errors to almost none.
                  Attached Files

                  Comment


                  • #10
                    Just to add my name to list of people seeing this.
                    Just created a script that reads my RC80's temp, outside temp and another aux temp sensor once every minute and update virtual devices with the readings.

                    I thought I was seeing things just before the web interface refreshed that outside was 9999.99 degree's Celsius (now that's hot!).

                    Hey Rick, my HAI plugin "issues" list is getting longer!
                    Added some zones to Omni the other day and thought I could just re-import the zones/units names... Nah.. Panel Comms errors.. So just ended up editing the settings.ini with zone names.

                    I'll give fixrim's idea a go.

                    Ross.

                    Comment


                    • #11
                      Yea, still seeing it here as well.

                      Seeing it a lot more now that I've started testing my new NetTouchPad TouchPad support for NetRemote. One of the TouchPad menu items is HVAC and I'm getting the errors when accessing the current termostat and outdoor (aux) temperatures.

                      I had to add a plugin error message to the termostat display screen to inform the user that I got a plugin error and for them to retry getting an update.

                      Just a friendly reminder that this is a paid for plugin that multiple users are experiencing issues with.

                      Comment


                      • #12
                        If the problem is a timeout or something a simple workaround I've found is to test for the two extremes. What I've noticed anyway is it either returns -99 or 9999.99 so this seems to be working fine:

                        ' Main Thermostat - Inside Temp
                        OldValue = hs.DeviceString("v40")
                        Value = hs.plugin("HAI_System").HAI_WhatIsTemp(1)
                        If StrComp(OldValue, Value) <> 0 And StrComp(Value, "-99") <> 0 And StrComp(Value, "9999.99") <> 0 Then
                        hs.SetDeviceString "v40",Value,TRUE
                        End If

                        Basically read the value, if it's different to what it was last read as, and not -99 and not 9999.99 then set the new value of the virual device. But I've only ever seen -99 and 9999.99 are there other values it returns?

                        This can fix the script side of things, but does it have the same problem using Temp zones for triggers directly?. Would setting an event to trigger for when "Outside Temp (4) Becomes Less than 10" then speak "It's really cold outside" might trigger on a 40 degree day?
                        Just created a trigger to find out so we'll see.

                        Ross.

                        Comment


                        • #13
                          Based on what Rick was telling me earlier on why the plugin was returning these values your trigger should work just fine. The bug happens to be only when you ask for a value when the plugin isn't prepared to give it to you. So a trigger on condition should work just fine because the plugin knows the value when it's ready to check the condition.

                          Comment


                          • #14
                            Rick,

                            Regarding the plugin possible rewrite.

                            Might want to make sure you use Overlapped I/O for your serial communication in Windows, though that is probably what you're talking about when you say interrupt driven.

                            And then enhance the scripting objects so that they are overloaded with versions that can be told to immediately return the value, and one that can be given a timeout to wait (ie: wait up to 2 secs for a response, and then send the old value on a timeout).

                            Very easy to do in Windows.

                            Comment


                            • #15
                              George, the friendly reminder should go to the company that you paid much bigger bucks to that gave you a piece of hardware that despite having its own brain, requires itself to be stupidly polled for data.

                              Yes, you could sort of look at the way I am going to rewrite it as overlapped I/O, but instead of waiting for a response at all, I am going to issue the command to get the status but return whatever value is in memory. Since the polling that goes on is not tied to any specific user interface event, I can do this and handle the response when it happens instead of waiting for it or expecting it to come back in a particular order. When you do something like bypass a zone on the Web UI, most of the time the command, action by the panel, panel writing to the event log, plug-in polling the event log and picking up the new status takes too long for the immediate page refresh to show the new status anyway, so this will not make any of that worse. When you do something like bypass a zone it generates an event that gets picked up right away with the fast poll, but thermostat items are not logged, so when you change the temperature setpoint for example, I will issue an immediate thermostat status query so it is forced to get an update.

                              We'll see how well it all works out - I am getting ready to begin work on it as HomeSeer 1.7 is about to be released.
                              Regards,

                              Rick Tinker (a.k.a. "Tink")

                              Comment

                              Working...
                              X