Public Sub Main(ByVal input As Object)
'Moskus 2020
Dim device As Scheduler.Classes.DeviceClass
Dim DE As Scheduler.Classes.clsDeviceEnumeration
Dim counter As Integer = 0
Dim counterBelow100 As Integer
Dim filter As String = "batter" 'tar da både "battery" og "batteri"
hs.WriteLog("Battery", "Looking for battery devices...")
DE = hs.GetDeviceEnumerator()
Do While Not DE.Finished
device = DE.GetNext
If device.Device_Type_String(hs).ToLower.Contains(filter) OrElse device.DeviceType_Get(hs).Device_Type_Description.ToLower.Contains(filter) OrElse device.Name(hs).Contains(filter) Then
Dim devName As String = device.Location2(hs) & ", " & device.Location(hs) & ", " & device.Name(hs)
Dim devValue As Double = hs.DeviceValueEx(device.Ref(hs))
If devValue < 100 Then
hs.WriteLog("Battery", "Device: " & devName & ", battery: " & devValue)
counterBelow100 += 1
End If
counter += 1
End If
Loop
hs.WriteLog("Battery", "Done! Found " & counter & " devices, " & counterBelow100 & " have levels below 100%.")
End Sub
Bare lagre som "GetBatteryLevels.vb" og kjør det. Det skrives til loggen.