No announcement yet. script classes?

  • Filter
  • Time
  • Show
Clear All
new posts script classes?


    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.

    Imports System.Collections.Generic
    Imports System.Diagnostics
    Private areas As New List(Of area)()
    Sub Main(ByVal Parm As String)
        Dim t As area
    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)
        End Sub
        Public Sub addTrigger(ByVal deviceRef As Integer)
        End Sub
    End Class

    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
    68 Z-Wave Nodes, 174 Events, 326 Devices
    UPB modules via OMNI plugin/panel
    Plugins: Z-Wave, OMNI, HSTouch, weatherXML, EasyTrigger
    HSTouch Clients: 3 Android, 1 Joggler