Announcement

Collapse
No announcement yet.

Energy Logging Script

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

  • Energy Logging Script

    HI,

    DOes someone succesfully have created a script to add a devicevalue to the energy database? If so i would love to see an example. I want to add this to several existing scripts i use, to interface devices.

    Regards

    Bart
    Regards Bart
    ------------------------------------------
    Win7 64Bit on Intel NUCI7 with SSD
    HSPRO 3.
    Devices; 1370 Events; 691

    Jon00 Scripts, JowHue, HSTouch, Plugwise, Z-wave, Ultranetatmo, Ultracam, PHlocation, BLUSBUIRT, MeiHarmony, Buienradar, MEiUnifi Pushover 3P, Random, Nest HSPhone and Blueiris

    Visonic Powermax Alarm System (HS3) Interface: http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129

  • #2
    Unfortunately whilst you can do this there is no support on the HS side of things yet, the Energy API is fixed with watts and that sort of stuff so you can add a value but it will be meaningless at the minute because it is designed for energy consumption/production rather than values. All of the charts are geared towards this and I imagine that HS will have to have an additional API when it comes to charting device values.
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      Hi mrhappy,

      I know its still limited for powerusage however. I manage a script to readout data from my housemeters abd i would like to trend this data. So i would like to see an example of registering a device in the energy DB and writing new data to it.

      thanks

      Bart
      Regards Bart
      ------------------------------------------
      Win7 64Bit on Intel NUCI7 with SSD
      HSPRO 3.
      Devices; 1370 Events; 691

      Jon00 Scripts, JowHue, HSTouch, Plugwise, Z-wave, Ultranetatmo, Ultracam, PHlocation, BLUSBUIRT, MeiHarmony, Buienradar, MEiUnifi Pushover 3P, Random, Nest HSPhone and Blueiris

      Visonic Powermax Alarm System (HS3) Interface: http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129

      Comment


      • #4
        Have you seen the stuff in this thread http://forums.homeseer.com/showthrea...ghlight=energy there are a few examples of how to log data to the DB, that would go in the recurring script. In your startup.vb file you would just need to call hs.Energy_SetEnergyDevice once to register the device for logging.
        My Plugins:

        Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
        Yeelight 3P | Nanoleaf 3P

        Comment


        • #5
          Hi,

          I need some help understanding the Energylogging. I have a script that reads out data from a device wich interfaces also my Smartmeters. I have several devices;

          Meter 1 and 2: KWH meter no decimalls (e.g. 52132 KWH)
          Dayusage 1, 2 total: KWH meter no decimalls (e.g. 12 KWH)
          Current Usage: Watt Meter with decimals (610 Watt)

          I would like to chart these devices with the energy graph, I am using this script which is being called every hour with a ref to the device wich to chart. This works fine and data being added, but the graphs are totally not as expected. Any ideas?:

          Code:
          Sub Main(Params as object)
            
          Dim DeviceID as String
          Dim Value
           DeviceID = Params
           Value = hs.DeviceValue(DeviceID) 
           
          Dim uD As New EnergyData(enumEnergyDirection.Consumed)
                       uD.dvRef = DeviceID
                      uD.Direction = enumEnergyDirection.Consumed
                      uD.Amount = Value
                      uD.Amount_Start = DateTime.Now.Addhours(-1)
                      uD.Amount_End = DateTime.Now
                      uD.Rate = 0
                      uD.UserCode = 0
                      uD.Device = enumEnergyDevice.Meter_Service
                           
            If Not hs.Energy_AddData(DeviceID, uD) Then
             hs.Energy_SetEnergyDevice(DeviceID, enumEnergyDevice.Meter)
             hs.WriteLog("AddEnergy", "Creating Energy device Database entry for " & DeviceID & " to HomeSeer.")
                 If Not hs.Energy_AddData(DeviceID, uD) Then
                        hs.WriteLog("AddEnergy", "Failed to add energy data received for " & DeviceID & " to HomeSeer.")
                 End If
              
              Else
                  hs.WriteLog("AddEnergy", "successfully added energy data " & Value & " for "& DeviceID)
           End If
           
            
            
            
          End Sub
          thanks

          Bart
          Regards Bart
          ------------------------------------------
          Win7 64Bit on Intel NUCI7 with SSD
          HSPRO 3.
          Devices; 1370 Events; 691

          Jon00 Scripts, JowHue, HSTouch, Plugwise, Z-wave, Ultranetatmo, Ultracam, PHlocation, BLUSBUIRT, MeiHarmony, Buienradar, MEiUnifi Pushover 3P, Random, Nest HSPhone and Blueiris

          Visonic Powermax Alarm System (HS3) Interface: http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129

          Comment


          • #6
            Bart,

            There is a challenge in the devices I guess. I assume your devices Meter 1 and 2 are holding a sum of usage during a longer period and keeps accumulating?
            For these devices all you could do is save the value somewhere and when you read the value in the script calculate differences between the last value and new values. As it is not holding decimals this will result in a rough number. Are these connected to the dayusage devices?

            The same will go for the dayusage I assume - it will accumulate during the day and jump back to 0 at the start of the day. I would suggest to handle it that way, only read it once a day at 23:59 or at least just before the reset will take place and add this to the energy database for a start at 00:00 and ending at 23:59. Still - as this value is not holding decimals - it will be a bit rough number.

            For the Watt meter you need to know what it is showing? Is this showing the current usage at this very moment? I do not think you can use this value for reporting KWh. It could change per second, and you would need to catch every change and calculate the KWh yourself - which will be really hard to get exact figures.
            -- Wim

            Plugins:RFXCOM, HSTouch Server, Squeezebox, BLGData, Restart, Jon00's Perfmon and Network monitor, WeatherXML, BLBackup, TenScripting, BC4, Pushover, PHLocation, JowiHue, Zwave, Sonos
            650 devices ---- 336 events ----- 40 scripts

            Comment


            • #7
              The energy DB from what I can fathom out is calculating kWh itself by using the wattage (.Amount) and then working out between Amount_Start and Amount_End how many hours that is. Multiply together and you of course have your kWh. If that device shows watts that second then you could get an event that triggers every time the device changes value then for Amount_Start I have used the hs.devicelastchange time and DateTime.Now to work out how much time that reading has been there to work out kWh.

              Issue being this can end up with a whole amount of data and the more you log the slower the energy page takes to render.
              My Plugins:

              Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
              Yeelight 3P | Nanoleaf 3P

              Comment


              • #8
                Hi,

                Thanks guys that was very helpfull!!

                Bart
                Regards Bart
                ------------------------------------------
                Win7 64Bit on Intel NUCI7 with SSD
                HSPRO 3.
                Devices; 1370 Events; 691

                Jon00 Scripts, JowHue, HSTouch, Plugwise, Z-wave, Ultranetatmo, Ultracam, PHlocation, BLUSBUIRT, MeiHarmony, Buienradar, MEiUnifi Pushover 3P, Random, Nest HSPhone and Blueiris

                Visonic Powermax Alarm System (HS3) Interface: http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129

                Comment


                • #9
                  Energy Loggin Script Fail

                  Trying to run this script above to update the energy graph. I get the following error in the log.
                  Running script C:\Program Files (x86)\HomeSeer HS3\scripts\EnergyLog.VB :Exception has been thrown by the target of an invocation.Conversion from string "Total House Current" to type 'Integer' is not valid.

                  Comment

                  Working...
                  X