Announcement

Collapse
No announcement yet.

vb.net script classes?

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

  • vb.net script classes?

    Hi,

    i'm trying to write a script that will allow me to easily set up moition detectors to activate lights the way i want without having to have loads and loads of events.

    My idea would be that i have a script with a list of different areas. i want 'area' to be a custom class but cant seem to get this to work, i'm not sure if i understand the architecure of hs right.


    in its simplest form i was going to add this to startup (to call main) and then register the change call back. Although im not sure if i can have classes like this, or even run a scrpt in this way and maintain as a single instance eg variables stay alive, between calls.

    Code:
    Imports System.Collections.Generic
    Imports System.Diagnostics
    
    Private areas As New List(Of area)()
    
    
    Sub Main(ByVal Parm As String)
    
        Dim t As area
        t.addLight(906)
        t.addTrigger(804)
        Me.areas.Add(t)
    
    
    End Sub
    
    Sub StatusChangeCB(ByVal Parm As Object())
        'check each area if callback is from trigger
        'if so turn on light
    End Sub
    
    
    Class area
    
        Public lights As New List(Of Integer)()
        Public triggers As New List(Of Integer)()
    
    
        Public Sub addLight(ByVal deviceRef As Integer)
            Me.lights.Add(deviceRef)
        End Sub
    
        Public Sub addTrigger(ByVal deviceRef As Integer)
            Me.lights.Add(deviceRef)
        End Sub
    
    
    End Class

  • #2
    You're on the right track. A user many years ago (@drozwood) showed how to have a single MasterScript.vb with multiple Subs. The idea is this is compiled once by HS instead of once for each individual script. You dont really need separate classes - just a single script with multiple Subs. If you do need multiple classes, consider putting them into their own script.
    HS3Pro Running on a Raspberry Pi3
    64 Z-Wave Nodes, 168 Events, 280 Devices
    UPB modules via OMNI plugin/panel
    Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
    HSTouch Clients: 3 Android, 1 Joggler

    Comment

    Working...
    X