Announcement

Collapse
No announcement yet.

What am I doing wrong ? - Solved!

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

    What am I doing wrong ? - Solved!

    Trying to read a sensor value from a file, and my script will not let me create a new device :

    ------------------------------------------------------------------
    sub main ()

    Dim dv
    Dim oFSO, sFile, oFile, sText, holder, dvRef

    Set oFSO = CreateObject("Scripting.FileSystemObject")
    sFile = "c:/ProgramData/masterbeddroom.txt"

    If oFSO.FileExists(sFile) Then

    If hs.DeviceExistsRef("/10") = "-1" then

    dv = hs.NewDeviceEx("Temperature")

    REM set the other properties

    dv.hc = "/"
    dv.dc = "10"
    dv.location = "Master Bedroom"
    dv.location2 = "Main Floor"
    dv.dev_type_string = "Status Only"

    hs.SaveEventsDevices()
    end if

    Set oFile = oFSO.OpenTextFile(sFile, 1)
    Do While Not oFile.AtEndOfStream
    sText = oFile.ReadLine

    hs.setdevicestring "/10",stext, True

    Loop
    oFile.Close

    -------------------------------------------------------

    I get this error message :

    "Running script, script run or compile error in file: Get Master Bedroom Temp.txt438:Object doesn't support this property or method in line 15 More info: Object doesn't support this property or method

    I tried defining the variable dv as an object at the start of the routine :

    "Dim dv as object"

    and I would get this error message :

    "Error - Running script, script run or compile error in file: Get Master Bedroom Temp.txt1025:Expected end of statement in line 3 More info: Expected end of statement"

    What am I doing wrong ?

    #2
    DeviceExistsRef returns a long value not a string.

    Try this
    If hs.DeviceExistsRef("/10") = -1 then


    Also check your log file for any errors.
    --
    Jeff Farmer
    HS 3, HSPhone
    My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
    Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

    Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

    Comment


      #3
      Ok, now the log file has a new error :

      "Running script, script run or compile error in file: Get Master Bedroom Temp.txt438:Object doesn't support this property or method in line 15 More info: Object doesn't support this property or method"

      which refers to the line :

      dv = hs.NewDeviceEx("Temperature")

      ???

      Comment


        #4
        I got it, everyone...

        I didn't use the "set" prefix prior to defining the new device.


        Thanks all !

        Comment


          #5
          One more question....

          Well, although I can now create the devices needed, unfortunately the "on" & "off" buttons still appear to the right of the status page.....even tho I specifically set the "status only" properties of the device :

          "dv.dev_type_string = "Status Only" "

          Any ideas how I might remove these buttons in the script ?

          Comment


            #6
            Originally posted by kruane View Post
            Well, although I can now create the devices needed, unfortunately the "on" & "off" buttons still appear to the right of the status page.....even tho I specifically set the "status only" properties of the device :

            "dv.dev_type_string = "Status Only" "

            Any ideas how I might remove these buttons in the script ?
            The dev_type_string setting just changes what is in the Type column in the web UI, I dont think it does anything else.

            You will need to set the .misc value to &H10 for a status only device, like this;

            dv.hc = "/"
            dv.dc = "10"
            dv.location = "Master Bedroom"
            dv.location2 = "Main Floor"
            dv.misc = &H10

            Comment


              #7
              Thanks, Happy...I appreciate it.

              Comment

              Working...
              X