Announcement

Collapse
No announcement yet.

Strange Ocelot/web results

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Strange Ocelot/web results

    I am having some really strange results when I try and switch inputs on/off on my Ocelot from the web and scripting interface.

    I am using the hs.devicevalue command reading '1' as on and '0' as off. I then use the set command to toggle these. It seems that if I do that the hs.ison and hs.isoff commands do not follow... it is like they conflict... Also after the set command the values do not always reflect the correct on/off states.
    (I am running the latest ADIOcelot plug-in)

    Here is my web code:
    <pre class="ip-ubbcode-code-pre">
    Function SpeakerControl(pDeviceName)
    Dim strStatusImage, strStatusText, strControl, iValue, strLabel, v
    'If hs.IsOff(pDeviceName) then
    If hs.devicevalue(pDeviceName) = 0 then
    strControl = 1
    strLabel = "Turn On"
    strStatusImage = hs.IsOn(pDeviceName) & pDeviceName & hs.devicevalue(pDeviceName) & "&lt;input src='icons/devices/soundoff.gif' type='image' align='absmiddle' title='" & strLabel & "'&gt;"
    Else
    strControl = 0
    strLabel = "Turn Off"
    strStatusImage = hs.IsOn(pDeviceName) & pDeviceName & hs.devicevalue(pDeviceName) & "&lt;input src='icons/devices/soundon.gif' type='image' align='absmiddle' title='" & strLabel & "'&gt;"
    end if

    SpeakerControl = "&lt;form method='POST' style='margin:0'&gt;" & strStatusImage & "&lt;input type='hidden' value='Image' name='Action'&gt;&lt;input type='hidden' value='hs.setdevicevalue """ & pDeviceName & """,""" & strControl &""" ' name='CommandImage'&gt;&lt;/form&gt;"

    End Function

    </pre>
    I have it print the output of both hs.ison and the devicevalue and they are not always the same.
    Here is a sample output from the above code.
    <pre class="ip-ubbcode-code-pre">
    DeviceCode hs.IsOn hsDeviceValue
    $9 True 0
    $10 True 1
    </pre>

    I am loosing my mind over this as I cannot figure out what is going on..

    #2
    hs.IsOn applies to the Device Status property while hs.DeviceValue applies to the Device Value property. If you consistently use hs.DeviceValue then you should have consistent results.

    I tried to extend the standard ocelot plugin by adding DeviceValue support and wanted to change the status each time the value changed. I used the DeviceValue as the true state and tried to have the DeviceStatus follow the DeviceValue. There are several logic paths where the transformation comes into play and I would rather not open it up again as the potential for breaking something else if this logic is changed.

    Comment


      #3
      My problem is that using the code above the device value returns random... somtimes it is one with a '1' and other times with a '0'

      I don't care which I use, I just need one to be consistent.

      Comment


        #4
        How do you know the values are "random" and not the actual values that the SECU is returning? Are you trying to set a value for an input device?

        I looked at the code and saw the following logic implemented:

        switch input changes, ocelot notifies IO change, plugin sets DeviceStatus and calls homeseer to notify of a value change with the value provided by the ocelot

        user calls SetDeviceValue for an output type device, homeseer calls SETIO of the plugin and the value is sent to the ocelot. If is is a change in value from what the ocelot previously had then it notifies the IO change and the previous paragraph applies.

        user calls SetDeviceValue for an input type device, homeseer calls SETIO of the plugin. Plugin ignores the request because this is an input and it cannot be set.

        user sets On/Off from GUI, homeseer calls SETIO of the plugin. Plugin translates an ON to 1 and anything else to 0 and this value sent to ocelot. If it is a change then ocelot notifies as above.

        User can set DeviceStatus and the value and the status will be out of sync. User can set DeviceValue of an input device and the hardware and homeseer will be out of sync. If the user sets DeviceValue of an output device then the status showing in the GUI should correlate with the value.

        Comment


          #5
          I know it's random because I can switch (change device value) on the web page and what is reflected back is not the same as what the Ocelot is doing, and is not always the same.

          I.E. Sometimes it says False, 1 - other times it says true,1 it will do this even with the speakers off... If I refresh the page it reads the same value, so it is not a delay item.

          If it was the same and I could apply logic to it's response and I could program to it... Right now all I see is random...

          Did you try the code above? It should work the same for you... if not then I have something else going on.

          Comment


            #6
            if pDeviceName (i.e. $9 or $10) is an SECU16 Input then you cannot change it from a web page. You can only change outputs. There is no way that the SECU16 can be commanded to change the value of an input. It can only report the value it sees from the external connection.

            Comment


              #7
              my $9, $10 are outputs...

              Comment


                #8
                I tried the following test program with my SECU16 and had consistent results. It commands a output then waits for the ocelot to act upon it and return an update status. Typically 4 seconds from command out to ocelot status back. If you check the deviceValue rather than the deviceStatus then you get the command value back right away since that comes directly from homeseer rather than from the result returned from the ocelot.

                If you test the deviceStatus faster than about 4 seconds after setDeviceValue is commanded then the status likely will not have updated yet. If you check deviceValue then you will have the eventual status, but the SECU16 output may not yet have taken on the new value.

                Depending upon what you want to accomplish either method will work.

                <pre class="ip-ubbcode-code-pre">

                set hs = createobject("Homeseer.application")

                hs.setDeviceValue "_11",1
                toOne = 0
                for i = 1 to 30
                if hs.IsOn("_11") Then
                toOne = i
                exit for
                else
                hs.waitsecs 1
                end if
                next
                toZero = 0
                hs.setDeviceValue "_11",0
                for i = 1 to 30
                if hs.IsOff("_11") then
                toZero = i
                exit for
                else
                hs.waitsecs 1
                end if
                next

                MsgBox ToOne & "," & ToZero


                </pre>

                Comment


                  #9
                  I really don't have any pf the same problems in scripting, I have only run into this with the web page I listed above... Has anyone tried the web code I posted above? I would be curious to see if you got the same results.

                  Comment


                    #10
                    What you are experiencing is the nature of the HS implementation in a single process thread. There have been discussions on this over the years.

                    As long as the asp is running there will be no other activity occurring. When you exit the web page (asp script finishes) then other activities will occur. You can set as many hs devices as you want, but these will all be queued up until the asp page is finished.

                    Comment


                      #11
                      I don't think that is what I am seeing here. I see a difference in what HS reports fro the devicevalue and the ison and isoff values. These seem to get out-of-sync, regardless of any running scripts. I can exit the page reboot my Audrey and the values are still out of sync.

                      Comment


                        #12
                        I dont know it this will make any difference, but I converted an ON/OFF into a SetDeviceStatus in the function that causes HS commands to be sent to the ocelot. This is in 1.6.14.

                        I also did not notice any explicit ocelot notification of relay changes which I expected.

                        With this change the commanded status will be transformed into an commanded value so value and status should now track immediately and will not depend on actual status returned from the ocelot. Later returned status could change the homeseer status, but the returned status should be the same as the commanded position if everyting is working.

                        Comment

                        Working...
                        X