Announcement

Collapse
No announcement yet.

Status Change Script

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

  • Status Change Script

    Trying to convert this script from HS2-HS3 that captures device changes to a virtual device. I have this script references in the startup.vb but the virtual device (v10) is not updating. I suspect it has to do with how the devices are referenced now?


    Code:
     Sub Main(ByVal Parms As Object)
    
    hs.writelog("Callback", "Registering for status change callback...")
    hs.RegisterStatusChangeCB("callback.vb", "Callback")
    
    End Sub
    
    Sub Unregister(ByVal Parms As Object)
    
    hs.writelog("Callback", "Unregistering for status change callback...")
    hs.UnRegisterStatusChangeCB
    
    
    End Sub
    
    Sub Callback(ByVal Parms As Object)
    
    Dim DCheck() As String ={"N1", "N3", "N5", "N7", "O1", "O3", "O5", "O7", "O9", "O11", "O13", "O15"}
    
    Dim DevStr As String = "V10" 'virtual device to update
    
    For Each s As String In DCheck
    
    If Parms(0) & Parms(1) = s Then 
    
    hs.writelog("Callback", "In the array...")
    
    If Parms(2) = 2 Then
    
    hs.writelog("Callback", "Device: " & Parms(0) & Parms(1) & " has turned on")
    
    'hs.setdevicestring(DevStr, hs.devicestringbyname(Parms(0) & Parms(1)), True)
    hs.setdevicestring (DevStr, hs.getdevicebyref(parms(3)).location, True)
    
    End If
    End If
    
    Next
    
    End Sub

  • #2
    I have a feeling I might have written that script (?), anyway a few changes need to be made to this script to get it to work again. This is a pointer as I don't use HS3 in reality so can't test it, I would guess at the following

    Code:
    Sub Callback(ByVal Parms As Object)
    
    Dim DCheck() As String ={"N1", "N3", "N5", "N7", "O1", "O3", "O5", "O7", "O9", "O11", "O13", "O15"}
    
    For Each s As String In DCheck
    
    If Parms(0).ToString = s Then 
    
    hs.writelog("Callback", "In the array...")
    
    If Convert.ToDouble(Parms(2)) = 100 Then 'I am guessing that 100 is on, could be different
    
    hs.writelog("Callback", "Device: " & Parms(0).ToString & " has turned on")
    
    hs.setdevicestring(1234, hs.getdevicebyref(parms(4)).location(hs), True) 'change first parameter to reference rather than code
    
    End If
    End If
    
    Next
    
    End Sub
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      Indeed this is your script! Question, I assume I still would need this at the top if I have it referenced in the startup.vb?

      Code:
       Sub Main(ByVal Parms As Object)
      
      hs.writelog("Callback", "Registering for status change callback...")
      hs.RegisterStatusChangeCB("callback.vb", "Callback")
      
      End Sub
      
      Sub Unregister(ByVal Parms As Object)
      
      hs.writelog("Callback", "Unregistering for status change callback...")
      hs.UnRegisterStatusChangeCB
      
      
      End Sub

      Comment


      • #4
        Originally posted by bmora View Post
        Indeed this is your script! Question, I assume I still would need this at the top if I have it referenced in the startup.vb?

        Code:
         Sub Main(ByVal Parms As Object)
        
        hs.writelog("Callback", "Registering for status change callback...")
        hs.RegisterStatusChangeCB("callback.vb", "Callback")
        
        End Sub
        
        Sub Unregister(ByVal Parms As Object)
        
        hs.writelog("Callback", "Unregistering for status change callback...")
        hs.UnRegisterStatusChangeCB
        
        
        End Sub
        Yep you still need those, both of the functions look to be broadly the same http://homeseer.com/support/homeseer...uschangecb.htm however what is returned is slightly different which means the callback script will change. Based on what the help file says I have made some amendments which I think might work.
        My Plugins:

        Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
        Yeelight 3P | Nanoleaf 3P

        Comment

        Working...
        X