YouLess LS110 Energy Monitor

Forum about Domotica, home automation and saving energy.

Re: YouLess LS110 Energy Monitor

Postby Rutger » Sat Feb 25, 2012 10:49 pm

Create two new virtual devices on the status page.

Copy complete script above.
Create an event, recurring, i.e: every 60 seconds
Add Action: run script
Create new one.
Name: i.e: Youless.vb
Open script window
Paste complete script and change ip address and both device codes A8 and A9 two new device codes you earlier created.
Rutger
Member
Member
 
Posts: 198
Joined: May 2010
Location: Netherlands

Re: YouLess LS110 Energy Monitor

Postby yellowbird » Sat Feb 25, 2012 10:56 pm

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
yellowbird
Starting Member
Starting Member
 
Posts: 2
Joined: February 2012

Re: YouLess LS110 Energy Monitor

Postby freakstar » Sun Feb 26, 2012 9:30 pm

How do i configure the virtual devices?
freakstar
Member
Member
 
Posts: 61
Joined: September 2011

Re: YouLess LS110 Energy Monitor

Postby Rutger » Sun Feb 26, 2012 10:58 pm

On your status page where all devices are visible, click on the left top on 'add device' and configure as you can see in the screenshot. Room and Floor will be different ofcourse.
No other configuration is necessarry. For the Youless script from Yellowbird, you'll have to add two virtual devices, like YL_Current and YL_Total.
The devicevalue and devicestatus will be updated when the script runs.
You do not have the required permissions to view the files attached to this post.
Rutger
Member
Member
 
Posts: 198
Joined: May 2010
Location: Netherlands

Re: YouLess LS110 Energy Monitor

Postby freakstar » Fri Jun 29, 2012 11:38 pm

Trying to get this script back to work after an stupid delete action...

Created an event with the following script:
Code: Select all
Imports System.Net

Sub Main (parm as Object)
   Dim strUrl As String = "http://192.168.1.9/a?f="
   Dim devIdCurrent As String = "Y1"
   Dim devIdTotal As String = "Y2"

   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


Created two "Status only" devices Y1 and Y2 for the values. When I run the script my HS log says:
Running script, script run or compile error in file: GetPwr1006:Expected ')' in line 3 More info: Expected ')'

Overlooked the script now like 10 times but can't find this fault?
freakstar
Member
Member
 
Posts: 61
Joined: September 2011

Re: YouLess LS110 Energy Monitor

Postby freakstar » Sun Jul 01, 2012 1:30 pm

Ah ja het truukje was opslaan als .vb...
freakstar
Member
Member
 
Posts: 61
Joined: September 2011

Re: YouLess LS110 Energy Monitor

Postby nikagl » Sat Sep 08, 2012 12:49 am

De code bevat nog een foutje volgens mij. Je pakt de substring fixed 7 lang bij het totaal gebruik. Dit zou e1 - s1 moeten zijn om de lengte van de string te krijgen...

Code: Select all
Imports System.Net

Sub Main (parm as Object)
   Dim strUrl As String = "http://192.168.1.9/a?f="
   Dim devIdCurrent As String = "v4"
   Dim devIdTotal As String = "v5"
   
   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() & " Watt")
   
   s1 = data.IndexOf("cnt") + 6
   e1 = data.IndexOf("pwr", s1) - 3
   
   total = Convert.ToDouble(data.SubString(s1,e1 - s1).Replace(",",""))/1000
   
   hs.SetDeviceValue(devIdTotal , total)
   hs.setdevicestring(devIdTotal , total.ToString() & " kWh")
End Sub


En voor degenen die deze code gebruiken, niet vergeten:

  • virtual devices aanmaken voor current en total
  • ip adres veranderen in youless ip-adres (192.168.1.9 vervangen)
  • v1 en v2 veranderen in de codes van jouw virtual devices
  • script plaatsen in scripts folder
  • event aanmaken dat script iedere X minuten runt
  • advies: zorg ervoor dat het event niet logt, anders heb je bij iedere execute een regel dat hij het script start

Voor dit alles ook nog even wat screenprints toegevoegd. Misschien handig voor diegenen die het willen gebruiken maar niet weten hoe...

Groet,

Nika.
You do not have the required permissions to view the files attached to this post.
nikagl
Starting Member
Starting Member
 
Posts: 43
Joined: June 2010

Previous

Return to Energycontrol & Home Automation Forum

Who is online

Users browsing this forum: No registered users and 1 guest