Code:
Sub Main(parm as object) Dim ColorString as String Dim Color as Integer Dim WattsNow as Double 'Old 47=Watts variable, 46=Amps1, 42=Amps2, 44=Watts1, 40=Watts2 'New 56=Watts variable, 46=Amps , , 44=Watts 'hs.WriteLog("Energy", "Energy.vb running") ''WattsNow = hs.deviceValue(44) + hs.DeviceValue(40) WattsNow = hs.deviceValue(44) hs.SetDeviceValueByRef(56, WattsNow, True) ''hs.WriteLog("Energy", "Current Power " & WattsNow & " watts. Water Heater=" & hs.CounterValue("Hot Water Minutes")) ' If WattsNow > hs.GetVar("maxamps") then ' hs.SaveVar("maxamps", WattsNow) ' hs.WriteLog("Energy", "MaxAmps updated to " & hs.GetVar("maxamps")) ' End if If WattsNow > 2000 then ColorString = "Red" Color = 1 Else If WattsNow > 1000 then ColorString = "Yellow" Color = 5 Else If WattsNow > 100 then ColorString = "Green" Color = 2 Else ColorString = "Blue" Color = 3 End If Dim devValue As Integer = hs.DeviceValue(41) ''hs.writelog("HSM Test", "Current: " & devValue & ", Target: " & Color & ", " & ColorString) If Color <> devValue Then hs.CAPIControlHandler(hs.CAPIGetSingleControl(41, false, ColorString, false, true)) End If End Sub
Leave a comment: