Announcement

Collapse
No announcement yet.

VB Script Help - Please

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

    VB Script Help - Please

    I'm new to Homeseer and I'm starting to play with scripts on my Hometroller Zee S2.

    I have started with the example scripts in the online documentation:-

    Sub Main(parms As Object)
    ScriptingReferences = System.Management;System.Managment.dll
    Dim dvRef as Integer
    Dim dv

    dvRef = hs.GetDeviceRefByName("Dining room Table lamp")
    if dvRef > 0 then
    Set dv = hs.GetDeviceByRef(dvRef)
    else
    hs.WriteLog "Error","Could not find the reference for the device specified."
    exit Sub
    end if
    hs.WriteLog "Info","The address for the device is " & dv.hc & dv.dc

    End Sub

    But this gives me the following errors:
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: 'End Namespace' without 'Namespace'.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Not valid as identifier.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Expected end of statement.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Expected 'End'.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Expected end of statement.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Expected 'End'.
    Apr-26 23:45:33 Error Compiling script /usr/local/HomeSeer/scripts/alarm_part_arm.vb: Expected 'End'.


    ANy help to get me going would be appreciated. Thanks

    #2
    Hi Nick,

    The scripting references need to be add to settings.ini found in the config folder not in the script like you are doing. You'll need to restart HS after making the change. Looking at the script you have posted, you don't actually need them for this particular script. It also looks like you are mixing vbscript and vb.net syntax. For the Zee S2, you need vb.net syntax. Many of the examples in the HS help file are using vbscript syntax. As an example for hs.writelog, you'll need
    Code:
    hs.WriteLog("Error","Could not find the reference for the device specified.")
    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Also you have some HS2 syntax in there, this may not be your fault as there are some leftovers in the documentation but dv.hc & dv.dc no longer exist in HS2.

      It might be best if you post what you would like out of a script and we could help.

      Comment


        #4
        Thanks sparkman / mrhappy, it got me a little further. Will keep digging.
        My end goal is to turn a fibaro rgbw output on and then off for 0.5 seconds.
        Started with the examples first, but got stuck.

        The latest is:

        Sub Main(parms As Object)
        Dim dvRef
        Dim dv

        dvRef = hs.GetDeviceRefByName("Dining room Table lamp")
        if dvRef > 0 then
        dv = hs.GetDeviceByRef(dvRef)
        hs.SetDeviceValueByRef(dvRef, 255, True)
        hs.WaitSecs(5)
        hs.SetDeviceValueByRef(dvRef, 0, True)
        else
        hs.WriteLog("Error","Could not find the reference for the device specified.")
        exit Sub
        end if

        End Sub

        This seems to work with no errors but doesent turn the dinning lamp on / off.
        trying the dining lamp as its an easier device than the fibaro rgbw.
        Would rather use the
        Technology Address ECD3E340-004-A1
        Than the name.
        Thanks again.
        Last edited by NickWren; April 27, 2016, 03:21 PM.

        Comment


          #5
          Solution

          Finally did it.
          Turned a device on and off for 4 seconds - didnt need 0.5 in the end.

          hs.CAPIControlHandler(hs.CAPIGetSingleControl(59,true ,"on",false,true))
          hs.WaitSecs(4)
          hs.CAPIControlHandler(hs.CAPIGetSingleControl(59,true ,"off",false,true))

          Where 59 is the devices Reference ID found at the top of its advanced tab.

          Comment


            #6
            Hi Nick,

            Sorry I missed your previous post, glad you got it resolved.

            Cheers
            Al
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment

            Working...
            X