Hi
Came across this script for checking doors and windows.
I have created two virtual devices with ref id 1027 (windows) and 1026 (doors).
But i get this error message: VB.Net script exception(0), re-starting: Object reference not set to an instance of an object
Running HS3 pro on win10.
Came across this script for checking doors and windows.
Code:
'these are the virtual devices to be updated by the script '1027 Windows '1026 Doors 'Use the reference ID of the door or window sensor devices in the arrays below dim array_windows() as string = {"1018"} dim array_doors() as string = {"1015"} dim windows_count as integer = 0 dim window_name as string = "" dim wstr as string = "" dim doors_count as integer = 0 dim door_name as String = "" dim dstr as string = "" Dim dv as Object 'Using 2 subs, one for doors and the other for windows 'WINDOWS sub windows(ByVal Parms as Object) Try windows_count = 0 window_name = "" wstr = "" for each devw as string in array_windows 'hs.writelog("Array", "Window " & window_name & " | Value " & hs.DeviceValue(devw)) if hs.DeviceValue(devw) = 1 then windows_count = windows_count + 1 dv = hs.GetDeviceByRef(devw) window_name = dv.Name(hs) wstr = wstr & window_name & ",<br>" hs.writelog("DoorWindow", window_name & " Open") 'hs.writelog("DoorWindow", array_windows) end if next If windows_count > 0 then hs.SetDeviceValueByRef(1027,100,true) hs.SetDeviceString(1027, wstr,true) Else hs.SetDeviceValueByRef(1027,0,true) hs.SetDeviceString(1027, "All Windows Closed",true) End If hs.writelog("DoorWindow", "Window Count: " & windows_count) Catch ex As Exception hs.WriteLog ("DoorWindow", "Error Window: " & ex.Message) End Try End Sub 'DOORS sub doors(ByVal Parms as Object) Try doors_count = 0 door_name = "" dstr = "" for each devd as string in array_doors 'hs.writelog("Array", "Door " & door_name & " | Value " & hs.DeviceValue(devd)) if hs.DeviceValue(devd) = 1 then dv = hs.GetDeviceByRef(devd) door_name = dv.Name(hs) doors_count = doors_count + 1 dstr = dstr & door_name & ",<br>" hs.writelog("DoorWindow", door_name & " Open") end if next If doors_count > 0 then hs.SetDeviceValueByRef(1026,100,true) hs.SetDeviceString(1026, dstr,true) Else hs.SetDeviceValueByRef(1026,0,true) hs.SetDeviceString(1026, "All Doors Closed",true) End If hs.writelog("DoorWindow", "Door Count: " & doors_count) Catch ex As Exception hs.WriteLog ("DoorWindow", "Error Door: " & ex.Message) End Try End Sub
But i get this error message: VB.Net script exception(0), re-starting: Object reference not set to an instance of an object
Running HS3 pro on win10.
Comment