Announcement

Collapse
No announcement yet.

Help with Youless device/script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with Youless device/script

    This is my first post here on the Homeseer forum.

    Im totally new and now have an working HS3 envoirement with some Visonic/Hue/Rfxcom devices. Also bought Imperihome and Jowihue plugin.
    It all works but have to learn a lot and reading here a lot of posts.
    Sorry if i post this in the wrong section but when i search for "Youless" i get zero hits.
    The only thing that wont work ok is the following:

    I have an Youless energymeter device which monitors my old energymeter.
    On an Dutch (Domoticaforum) forum i found some info how to install this device:
    Make 2 virtual devices and let them update every minute with an event.
    This works, only problem i think is that there is coming no data in the Value field, only in the "String" field.
    So 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.
    Is there a solution and will somebody look in the attached script what is the problem?

    (I had to change the file extension from .vb to .txt otherwise i could not upload the file)
    Thanks
    Attached Files

    #2
    Your code is incorrect.

    Rather than:

    hs.SetDeviceValue(devIdCurrent, current)
    and
    hs.SetDeviceValue(devIdTotal , total)

    Replace with:

    hs.SetDeviceValueByRef(devIdCurrent , current, True)
    and
    hs.SetDeviceValueByRef(devIdTotal , total, True)


    FYI, Jon00 Database Charting does have a method to log from numerical data within device strings!
    Jon

    Comment


      #3
      Wow Jon,

      Thats an quick answer, im gonna try it!

      Egbert

      Comment


        #4
        Jon00 i can confirm that its working now.

        Comment


          #5
          Thanks, i just found this topic to

          I also had the following two script that aren`t working. But i gues i can get them to work now

          Create Night count

          Code:
          Sub Main(parm as object)
          hs.SetDeviceValue("449", hs.DeviceValue("448") )
          hs.SetDeviceLastChange("449",now)
          End Sub
          Create Day Usage

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

          Comment


            #6
            Hi there,

            I'm using successfully below VB script to update current and total kWh values in HS3.
            Does anybody has code for reading out gas meter readings?

            Code:
            Imports System.Net
            
            Sub Main (parm as Object)
               Dim strUrl As String = "http://192.168.97.20/a?f="
               Dim devIdCurrent As String = "3456"
               Dim devIdTotal As String = "3457"
            
               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.SetDeviceValueByRef(devIdCurrent, current, true)
               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.SetDeviceValueByRef(devIdTotal , total, true)
               hs.SetDeviceString(devIdTotal , total & " kWh", True)
            End Sub

            Comment

            Working...
            X