Announcement

Collapse
No announcement yet.

DeviceLastChangeRef very slow

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

  • DeviceLastChangeRef very slow

    I have a script that displays my 480 devices and I'm trying to display the Last Changed value. I can access this value with hs.DeviceLastChangeRef(dv.Ref(hs)) but it is very slow - it takes about 12 seconds to display the 480 devices. All the other information about the device I can retrieve directly from the dv object, so if I exclude the Last Change data the 480 devices display quickly.

    I can substitute hs.DeviceLastChange(devicename) which runs very fast but reports the last change as 12:00:00 AM for every device. I suspect this function is still not properly working in HS3 from when the bug was first reported in 2016.

    Am I interpreting what is happening correctly? Any way around this problem?

    (For those who would respond by asking why I want to display 480 devices, I don't - I want to be able to easily display a subset of devices - say, all the devices in the kitchen, or all the devices outside - with a single click, since I refer to them regularly in this fashion - and I am tired of the very poor HS3 user interface design to do this.)

    Thanks in advance for any help ...

  • #2
    Originally posted by jwshome2 View Post
    I have a script that displays my 480 devices and I'm trying to display the Last Changed value. I can access this value with hs.DeviceLastChangeRef(dv.Ref(hs)) but it is very slow - it takes about 12 seconds to display the 480 devices. All the other information about the device I can retrieve directly from the dv object, so if I exclude the Last Change data the 480 devices display quickly.

    I can substitute hs.DeviceLastChange(devicename) which runs very fast but reports the last change as 12:00:00 AM for every device. I suspect this function is still not properly working in HS3 from when the bug was first reported in 2016.

    Am I interpreting what is happening correctly? Any way around this problem?

    (For those who would respond by asking why I want to display 480 devices, I don't - I want to be able to easily display a subset of devices - say, all the devices in the kitchen, or all the devices outside - with a single click, since I refer to them regularly in this fashion - and I am tired of the very poor HS3 user interface design to do this.)

    Thanks in advance for any help ...
    One thing is that when you retrieve the device reference with dv.Ref(hs) you are reloading the device object from the database. As you have already created a copy of the object, dv, you can retrieve the reference from that i.e. dv.Ref(nothing) which should be a lot quicker.
    Only use the IHSApplication if you are retrieving something that might have changed since you created your copy of the hs object.

    Steve

    Comment


    • #3
      Thanks for the quick reply - I assumed the slow speed was because something was being repeatedly loaded, but I didn't know how to stop that.

      However - I tried hs.DeviceLastChangeRef(dv.Ref()) and got an error - here's the code:

      Script error: Invalid procedure call or argument: 'dv.Ref'

      if hs.DeviceLastChangeRef(dv.Ref()) = "12:00:00 AM" then change(i) = ""
      Is my syntax wrong?

      Regards.

      Comment


      • #4
        Originally posted by jwshome2 View Post
        Thanks for the quick reply - I assumed the slow speed was because something was being repeatedly loaded, but I didn't know how to stop that.

        However - I tried hs.DeviceLastChangeRef(dv.Ref()) and got an error - here's the code:



        Is my syntax wrong?

        Regards.
        The syntax should be as I stated above dv.ref(Nothing)

        You need the value for the parameter, that being Nothing.

        hs.DeviceLastChangeRef(dv.Ref(Nothing))

        Steve

        Comment


        • #5
          Also, can't you return the last change time directly from the object?

          dv.Last_Change(Nothing)

          Again use (hs) if you want to retrieve this from the IHSApplication or (Nothing) if it won't have changed since you created your copy.

          Steve

          Comment


          • #6
            Oh! Sorry, I've never seen the concept of 'Nothing' being spelled out, I assumed wrong. This fixed the syntax error but did not improve the speed. With the following lines of code HS3 takes 12 seconds to run; without them it takes less than one second.

            if hs.DeviceLastChangeRef(dv.Ref(Nothing)) = "12:00:00 AM" then
            change(i) = ""
            else
            change(i) = hs.DeviceLastChangeRef(dv.Ref(Nothing))
            end if

            Comment


            • #7
              I also just tried
              dv.LastChange(Nothing) and got the error
              Script error: Object doesn't support this property or method: 'dv.LastChange'

              Comment


              • #8
                Sorry again! I see you suggested Last_Change, I will try again ...

                Comment


                • #9
                  That works. Really appreciate the help, and apologies for my carelessness.

                  I've tried before and occasionally found comprehensive definitions of the objects in HS3 - since you seem to really know the object definitions, can you point me to the document? I know it exists ...

                  Comment


                  • #10
                    Originally posted by jwshome2 View Post
                    That works. Really appreciate the help, and apologies for my carelessness.

                    I've tried before and occasionally found comprehensive definitions of the objects in HS3 - since you seem to really know the object definitions, can you point me to the document? I know it exists ...
                    No problem. It's important to appreciate when you do and don't need to reference the IHSApplication as it has a significant overhead.

                    It's all the HS3 help file
                    https://help.homeseer.com/help/HS3/static/

                    ...in the scripting section.

                    The link below is to The Device Class
                    https://help.homeseer.com/help/HS3/s...s_deviceclass1

                    Comment

                    Working...
                    X