Page 2 of 2

Re: YouLess LS110 Energy Monitor

Posted: Sat Feb 25, 2012 10:49 pm
by Rutger
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.

Re: YouLess LS110 Energy Monitor

Posted: Sat Feb 25, 2012 10:56 pm
by yellowbird
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

Re: YouLess LS110 Energy Monitor

Posted: Sun Feb 26, 2012 9:30 pm
by freakstar
How do i configure the virtual devices?

Re: YouLess LS110 Energy Monitor

Posted: Sun Feb 26, 2012 10:58 pm
by Rutger
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.

Re: YouLess LS110 Energy Monitor

Posted: Fri Jun 29, 2012 11:38 pm
by freakstar
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?

Re: YouLess LS110 Energy Monitor

Posted: Sun Jul 01, 2012 1:30 pm
by freakstar
Ah ja het truukje was opslaan als .vb...

Re: YouLess LS110 Energy Monitor

Posted: Sat Sep 08, 2012 12:49 am
by nikagl
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.

Re: YouLess LS110 Energy Monitor

Posted: Fri Jan 24, 2014 12:12 am
by raymonvdm
I just added this script to my HomeSeer and it is working fine :D

I also use two scripts to create a day usage counter (script was used for the NorthQ before, maybe it it not completely working due to DeviceString versus DeviceValue issues)

This one copies the current usage to another virtual device (running at 23:59)

Code: Select all


Sub Main(parm as object)
hs.SetDeviceString("K74", hs.DeviceString("K76") )
hs.SetDeviceLastChange("K74",now)
End Sub

This one calculates the usage of the last 24 hours using the value saved in the day before (running at 23:54)

Code: Select all


Sub Main(parm as object)
hs.SetDeviceString("K73", CStr( hs.DeviceValue("K76") - hs.DeviceString("K74") ) /100 )
hs.SetDeviceLastChange("K73",now)
End Sub


My devices are

Code: Select all


YouLess_Total_Day_Usage	  0	                Beganegrond	Meterkast	YouLess_Total_Day_Usage	        K73	Status Only	 Today 23:05:50	
Youless_Total_Yesterday	  39825,715 kWh 	Beganegrond	Meterkast	Youless_Total_Yesterday	        K74	Status Only	 Today 23:06:55	
YouLess Current	          696 Watt         	Beganegrond	Meterkast	YouLess Current	                K75	Status Only	 Today 23:12:26	
YouLess Total	          39825,786 kWh	        Beganegrond	Meterkast	YouLess Total	                K76	Status Only	 Today 22:52:26


Re: YouLess LS110 Energy Monitor

Posted: Thu Jul 17, 2014 3:13 pm
by freakstar
Made some changes to get the script ready for HomeSeer 3:

Code: Select all

Imports System.Net

Sub Main (parm as Object)
   Dim strUrl As String = "http://192.168.1.14/a?f="
   Dim devIdCurrent As String = "117"
   Dim devIdTotal As String = "120"
   
   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 & " Watt", True)
   
   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 & " kWh", True)
End Sub
Using the Reference ID to point to the virtual devices, don't know what to use to get it working with the Technology Address attribute?

Re: YouLess LS110 Energy Monitor

Posted: Tue Apr 07, 2015 10:00 am
by raymonvdm
I migrated to HS3 and these are my YouLess Scripts the last one is working fine now the other two in need to verify


These are the scripts

Maak_Nachtstand_Youless.vb

Code: Select all

Sub Main(parm as object)
hs.SetDeviceValue("449", hs.DeviceValue("448") )
hs.SetDeviceLastChange("449",now)
End Sub

Maak_Verbruik_Youless.vb

Code: Select all

Sub Main(parm as object)
hs.SetDeviceValue("450", CStr( hs.DeviceValue("448") - hs.DeviceValue("449") ) )
hs.SetDeviceLastChange("450",now)
End Sub
youless_update_HS3.vb

Code: Select all

Imports System.Net

Sub Main (parm as Object)
   Dim strUrl As String = "http://192.168.140.150/a?f="
   Dim devIdCurrent As String = "447"
   Dim devIdTotal As String = "448"
   
   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 & " Watt", True)
   
   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 & " kWh", True)
End Sub

Re: YouLess LS110 Energy Monitor

Posted: Wed Dec 16, 2015 6:03 pm
by raymonvdm
Is there somebody with a little more scripting experience who can fix the first two scripts for me. I want to create a value each night around 23:59 and extract the next night value from it to get a day usage of the last day

Re: YouLess LS110 Energy Monitor

Posted: Mon Oct 31, 2016 9:25 pm
by egbertje
This is an old topic but i am totally new to Homeseer and i have a problem with this script.

It all works but when i want to log the data for example to use in Jon00 database or in Imperihome or in Device history, nothing will be logged.
I think the problem is that there is coming no data in the Value field , only in the "string" field, and the plugins get the data from the Value.
Is this possible to change something in this script?

Re: YouLess LS110 Energy Monitor

Posted: Sun Feb 12, 2017 10:03 pm
by erwindr
I think the problem is that there is coming no data in the Value field , only in the "string" field, and the plugins get the data from the Value.
Is this possible to change something in this script?
The device string is set correctly, but the value is indeed empty. Just a small change in the syntax.
Edit this:

hs.SetDeviceValue(devIdCurrent, current)
to
hs.SetDeviceValueByRef(devIdCurrent, current, true)

and

hs.SetDeviceValue(devIdTotal , total)
to
hs.SetDeviceValueByRef(devIdTotal , total, true)

Re: YouLess LS110 Energy Monitor

Posted: Sat Nov 17, 2018 12:37 pm
by djanssen
Hi there,

This is my script that I use to have current and total kWh values in Homeseer 3.

Is there anybody who have added also his gas meter reading in HS3 with a Youless monitor and is willing to share his script for this?

Maybe some other scripts for HS3 like last day usage / current day usage that are used are welcome as well

Daan