joda, det står at den mangeler/ forventer ) i første linje, men ser ikke hel problemet. Dette er srciptet.
Sub Main(params as Object)
Dim devRefNow as Integer = 880
Dim devRefPrev as Integer = 877
Dim devRefWatts as Integer = 876
Dim devRefWattsDayHi as Integer = 878
Dim devRefWattsDayLo as Integer = 879
Dim dateNow As Date = hs.DeviceLastChangeRef(devRefNow)
Dim datePrev As Date = hs.DeviceLastChangeRef(devRefPrev)
Dim kWhNow as Double = hs.DeviceValueEx(devRefNow)
Dim kWhPrev As Double = hs.DeviceValueEx(devrefPrev)
Dim wattsDayHi As Integer = hs.DeviceValueEx(devRefWattsDayHi)
Dim wattsDayLo As Integer = hs.DeviceValueEx(devRefWattsDayLo)
Dim watts As Integer = Math.Round(1000 * (kWhNow - kWhPrev) / dateNow.Subtract(datePrev).TotalHours, 0)
hs.writelog("NorthQ","NorthQ VP - Current kWh: " & kWhNow & " Previous kWh: " & kWhPrev & " Current W: " & watts)
hs.SetDeviceValueByRef(devRefWatts, watts, True)
hs.SetDeviceString(devRefWatts, watts & " W", False)
hs.SetDeviceValueByRef(devRefPrev, kWhNow, True)
hs.SetDeviceString(devRefPrev, kWhPrev & " kWh", False)
if wattsDayHi < watts then
hs.SetDeviceValueByRef(devRefWattsDayHi, watts, True)
hs.SetDeviceString(devRefWattsDayHi, watts & " W", False)
End if
if wattsDayLo > watts then
hs.SetDeviceValueByRef(devRefWattsDayLo, watts, True)
hs.SetDeviceString(devRefWattsDayLo, watts & " W", False)
End if
End Sub