Rutger wrote:Hi Yellowbird,
Thnx for your script.
My counter have 3 digits behind the komma.
The youless counter is on 29661,544 kWh.
In Homeseer I see the value 296615. Your script have the komma 1 place too far to the right?
Do you have the same experience?
I assumed a fixed length for the total energy usage and it showed Wh instead of kWh, mine is just turned on since yesterday so I have very low kWh number. Here is an updated version that I think should solve it and also display the value in kWh.
Imports System.Net
Sub Main(parm as object)
Dim strUrl As String = "http://192.168.1.230/a?f="
Dim devIdCurrent As String = "A8"
Dim devIdTotal As String = "A9"
Dim request As WebRequest = WebRequest.Create(strUrl)
Dim response As WebResponse = request.GetResponse()
Dim data as String = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd()
Dim s1 As Integer
Dim e1 As Integer
Dim current As Integer
Dim total As Double
s1 = data.IndexOf("pwr") + 5
e1 = data.IndexOf(",", s1)
current = Convert.ToInt32(data.SubString(s1,e1 - s1))
hs.SetDeviceValue(devIdCurrent, current)
hs.setdevicestring(devIdCurrent, current.ToString() & "W")
s1 = data.IndexOf("cnt") + 6
e1 = data.IndexOf("pwr", s1) - 3
total = Convert.ToDouble(data.SubString(s1,7).Replace(",",""))/1000
hs.SetDeviceValue(devIdTotal , total)
hs.setdevicestring(devIdTotal , total.ToString() & "kWh")
End Sub