SmartToggle.vb
 
	"Toggler" en device mellom "Off" og "On Last Level" hvis den finnes (altså er en Z-wave device). Kun mellom "Off" og "On" ellers.
 
	 
 
	Parameter: 400
 
	... der 400 er device ref til device'n du vil toggle.
 
Public Sub Main(ByVal input As Object)
    '© Moskus 2015
    Dim control As String = input
    Dim devicevalue As Double = hs.DeviceValueEx(control)
    Dim capi As HomeSeerAPI.CAPIControl = Nothing
    If devicevalue = 0 Then 'device is off, so let's trigger "On Last Level" if it exists on the device, and just "On"
        capi = hs.CAPIGetSingleControl(input, True, "on last level", False, False)
        If capi Is Nothing Then '"On last Level" wasn't found, so we need to find "On"
            capi = hs.CAPIGetSingleControl(input, True, "on", False, False)
        End If
    Else 'The device is on, so let's turn it offf
        capi = hs.CAPIGetSingleControl(input, True, "off", False, False)
    End If
    If capi IsNot Nothing Then
        hs.CAPIControlHandler(capi)
    Else
        hs.WriteLog("SmartToggle", "Could not execute CAPIcontrol, it's nothing! (Input device value: " & devicevalue & ")")
    End If
End Sub
	 
 
	 
 
	Eventet ser da slik ut: