Announcement

Collapse
No announcement yet.

Help with an error in an old HS1 script

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

    Help with an error in an old HS1 script

    Hi All,

    I finally made the switch to HS2 and need some help fixing an error in an old motion sensor script. I have 0 ability to script so any help is welcome. Although the script appears to be working fine, I get the following error:

    - Warning - GetDevice is not reliable for device enumeration. Please use the new GetDeviceEnumerator method.

    Can ne1 make the required change in the sript that follows:

    sub main()

    dim p, device_count, device, un, ty, tim, hour, t, nam, loc, fl, fs, day, tru, ss

    ' Set Fail-Safe = 3 mintues
    fs=3

    'Determine the number of devices in HomeSeer
    device_count=hs.devicecount

    ' Start the checking process
    for p = 1 to device_count

    ' Set variables
    set device = hs.getdevice(p)
    ty=device.dev_type_string

    ' Determine if device is a Motion Sensor
    tru = 0
    if ty = "Motion Sensor" then tru=1
    if ty = "MS13A (Hawkeye II)" then tru=1
    if tru = 1 then

    ' Set variables
    un=device.hc+device.dc
    nam=device.name
    loc=device.location
    fl=hs.devicestring(un)

    ' Fail-Safe Turn Off
    if fs<>0 then
    if hs.ison(un) and hs.devicetime(un)=fs then
    hs.setdevicestatus un,"3"
    ' hs.writelog "MOTION","><><><>< Fail-safe was invoked - " &loc &" " &nam
    t="<table bgcolor="#460000" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td width="100%"> No Motion (00:00)</td></tr></tbody></table>"
    hs.SetDeviceString un,t
    fl="<"
    end if
    end if

    ' If the sensor is on then the following takes place
    if hs.ison(un) then
    if mid(fl,113,14)<>"motiondetected" then
    'if fl<>"Motion Detected" then
    ss="<table bgcolor="#ffff00" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td width="100%"> Motion Detected</td></tr></tbody></table>"
    hs.setdevicestring un,ss
    fl=mid(fl,204,6)
    if right(fl,1)=")" then fl=left(fl,5)
    ' hs.writelog "MOTION",">>>>>>>> Motion Detected - "+nam+" "+loc+" - No Motion ("+fl+")"
    end if
    end if

    ' If the sensor is off then the following takes place
    if hs.isoff(un) then
    tim=hs.devicetime(un)
    hour=int(tim/60)
    tim=tim-(hour*60)
    if len(tim)<2 then tim="0"+(cstr(tim))
    tim=hour&":"&tim
    if len(tim)<5 then tim="0"+tim
    t="<table bgcolor="#460000" border="0" cellpadding="2" cellspacing="0" width="100%"><tbody><tr><td width="100%"> No Motion ("+tim+")</td></tr></tbody></table>"
    hs.SetDeviceString un,t
    ' if mid(fl,199,1)="M" then hs.writelog "MOTION","<<<<<<<< No Motion Detected - "+nam+" "+loc
    end if
    end if
    next

    ' This section determines how long HomeSeer has been active
    tim=hs.devicetime("y2")
    hour=int(tim/60)
    day=int(hour/24)
    tim=tim-(hour*60)
    hour=hour-(day*24)
    if len(tim)<2 then tim="0"+(cstr(tim))
    tim=hour&" : "&tim
    if len(tim)<7 then tim="0"+tim
    tim=day&" : "&tim
    if len(tim)<12 then tim="0"+tim
    tim="<table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td width="100%">"+" "+tim+"</td></tr></tbody></table>"
    hs.setdevicestring ("y1"),tim

    end sub


    Many thanks

    #2
    Having the same problem moving to hometroller 2

    I found the code that is cause my problem just need to know what to change also.

    this is the code with the problem.
    ' Set variables
    set device = hs.getdevice(p)
    ty=device.dev_type_string

    giving the error message
    ~!~Warning~!~GetDevice is not reliable for device enumeration. Please use the new GetDeviceEnumerator method.

    Comment


      #3
      HomeSeer Online Help will be your best friend for help with scripting! Navigate to Using Scripts / Scripting Functions / For Devices, check out the GetDevice entry and you will find that this function has been deprecated (obsoleted). In the warning section at the bottom you will see that HS recommends using GetDeviceEnumerator instead. Give a shout if you get stuck changing this over.
      Best regards,
      -Mark-

      If you're not out on the edge, you're taking up too much room!
      Interested in 3D maps? Check out my company site: Solid Terrain Modeling

      Comment


        #4
        Thanks - I think the problem is clear now. My problem is I suck at scripting and have no know clue how to replace GetDevice with GetDeviceEnumerator. I was hoping someone with some scripting ability could make the change in the above script and post.

        Thanks
        BucK

        Comment


          #5
          Can ne1 fix this script for me??

          Comment


            #6
            Originally posted by BucK View Post
            Thanks - I think the problem is clear now. My problem is I suck at scripting and have no know clue how to replace GetDevice with GetDeviceEnumerator. I was hoping someone with some scripting ability could make the change in the above script and post.
            The only way to not suck at scripting is to learn how to do it.

            Please re-post your script code either as an attachment or in PHP tags (highlight your code then click the PHP button) so that the HTML code in your script is not mangled and I'll make the change for you.
            Best regards,
            -Mark-

            If you're not out on the edge, you're taking up too much room!
            Interested in 3D maps? Check out my company site: Solid Terrain Modeling

            Comment


              #7
              Many thanks in advance Mark - script is attached
              Attached Files

              Comment


                #8
                Buck, give the attached a try. I'm sure there will be issues so please let me know the errors and I'll fix them.
                Attached Files
                Best regards,
                -Mark-

                If you're not out on the edge, you're taking up too much room!
                Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                Comment


                  #9
                  Many thanks for looking at this for me Mark - much appreciated. Getting one error:

                  9/26/2008 6:25:26 PM - Error - Running script, script run or compile error in file: motionsensor.txt1017:Expected 'Then' in line 38 More info: Expected 'Then'


                  thanks
                  BucK

                  Comment


                    #10
                    Oops, my bad. Try the attached. -Mark-
                    Attached Files
                    Best regards,
                    -Mark-

                    If you're not out on the edge, you're taking up too much room!
                    Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                    Comment


                      #11
                      Thanks again - now getting this error:

                      9/27/2008 8:15:38 AM - Error - Running script, script run or compile error in file: motionsensor.txt1038:'loop' without 'do' in line 96 More info: 'loop' without 'do'

                      I appreciate your help with this!!

                      Comment


                        #12
                        Let's try again....
                        Attached Files
                        Best regards,
                        -Mark-

                        If you're not out on the edge, you're taking up too much room!
                        Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                        Comment


                          #13
                          Many Many thanks - working like a charm

                          Really appreciate your help

                          Comment


                            #14
                            Glad it's working - enjoy!
                            Best regards,
                            -Mark-

                            If you're not out on the edge, you're taking up too much room!
                            Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                            Comment

                            Working...
                            X