YouLess LS110 Energy Monitor

Forum about Domotica, home automation and saving energy.

Re: YouLess LS110 Energy Monitor

Postby Rutger » Sat Feb 25, 2012 9: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.
My home automation blog: https://rutg3r.com
Rutger
Member
Member
 
Posts: 328
Joined: May 2010
Location: Netherlands

Re: YouLess LS110 Energy Monitor

Postby yellowbird » Sat Feb 25, 2012 9: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 8:30 pm

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

Re: YouLess LS110 Energy Monitor

Postby Rutger » Sun Feb 26, 2012 9: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.
Attachments
newdevice.jpg
newdevice.jpg (37.23 KiB) Viewed 8644 times
My home automation blog: https://rutg3r.com
Rutger
Member
Member
 
Posts: 328
Joined: May 2010
Location: Netherlands

Re: YouLess LS110 Energy Monitor

Postby freakstar » Fri Jun 29, 2012 10: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: 117
Joined: September 2011

Re: YouLess LS110 Energy Monitor

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

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

Re: YouLess LS110 Energy Monitor

Postby nikagl » Fri Sep 07, 2012 11:49 pm

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.
Attachments
7. Event Trigger.png
7. Event Trigger.png (13.94 KiB) Viewed 8590 times
6. Event Properties.png
6. Event Properties.png (20.02 KiB) Viewed 8590 times
5. Virtual Device YouLess Total Options.png
5. Virtual Device YouLess Total Options.png (16.53 KiB) Viewed 8590 times
4. Virtual Device YouLess Total Config.png
4. Virtual Device YouLess Total Config.png (14.56 KiB) Viewed 8590 times
3. Virtual Device YouLess Current Options.png
3. Virtual Device YouLess Current Options.png (13.29 KiB) Viewed 8590 times
2. Virtual Device YouLess Current Config.png
2. Virtual Device YouLess Current Config.png (20.57 KiB) Viewed 8590 times
nikagl
Member
Member
 
Posts: 54
Joined: June 2010

Re: YouLess LS110 Energy Monitor

Postby raymonvdm » Thu Jan 23, 2014 11:12 pm

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

Running HS3PRO on PC with Z-Wave / OpenTherm / Plugwise / RFXcom / MQTT / XAP400 / Logitech Media Server and Squeezelite on PI`s
raymonvdm
Senior Member
Senior Member
 
Posts: 1128
Joined: December 2011

Re: YouLess LS110 Energy Monitor

Postby freakstar » Thu Jul 17, 2014 2:13 pm

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?
freakstar
Member
Member
 
Posts: 117
Joined: September 2011

Re: YouLess LS110 Energy Monitor

Postby raymonvdm » Tue Apr 07, 2015 9:00 am

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
Running HS3PRO on PC with Z-Wave / OpenTherm / Plugwise / RFXcom / MQTT / XAP400 / Logitech Media Server and Squeezelite on PI`s
raymonvdm
Senior Member
Senior Member
 
Posts: 1128
Joined: December 2011

Re: YouLess LS110 Energy Monitor

Postby raymonvdm » Wed Dec 16, 2015 5:03 pm

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
Running HS3PRO on PC with Z-Wave / OpenTherm / Plugwise / RFXcom / MQTT / XAP400 / Logitech Media Server and Squeezelite on PI`s
raymonvdm
Senior Member
Senior Member
 
Posts: 1128
Joined: December 2011

Re: YouLess LS110 Energy Monitor

Postby egbertje » Mon Oct 31, 2016 8:25 pm

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?
Homeseer 3 on andere Intel Nuc/Win10
Plugins Imperihome Jowihue Rfxcom Pushover P1
RFXcom V3 Visonic Powermax+ some KaKu
egbertje
Starting Member
Starting Member
 
Posts: 24
Joined: April 2012

Re: YouLess LS110 Energy Monitor

Postby erwindr » Sun Feb 12, 2017 9:03 pm

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)
HS3 Pro 3.0.0.298, W10 on Atom x5-Z8300
SqueezeBox, UltraM1G3, UltraMon3, Z-Wave

HS2 Pro 2.5.0.80, W2k3 on AMD X2
X10 CM11A/CM12U, SqueezeB, UltraMon, tenHsPower, UltraM1G, SqueezeBox
User avatar
erwindr
Starting Member
Starting Member
 
Posts: 5
Joined: May 2011

Previous

Return to Energycontrol & Home Automation Forum

Who is online

Users browsing this forum: No registered users and 1 guest