Announcement

Collapse
No announcement yet.

Time Totallizing Script

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

  • Time Totallizing Script

    Hi:
    I would like to keep track of the amount of time our cabin furnace runs. I presently have HS send me an email every time it goes on off and I would like to totalize the time automatically. Manual addition is a drag. The elapsed running can be correlated to propane consumption and that is what I am actually after.

    I have asked about this before and at that time nobody had created such a script. This would seem to be a very useful thing and I would think someone would have done it by now. One event could turn it on and another event could turn it off. Seems simple but I am not a scripter.

    Right now I have a mechanical hour meter keeping track of it , but I would like to get something that could generate a text or csv file so that I have a permenant record of it.

    Anybody ever done anything like this?

    Thanks, John

  • #2
    Here is a spin off of Jon00 's script to "get" the world population and put it into a virtual device.

    Notice where I put the delta= ?

    Just do something similar, except you will want to also do a few other things.

    First, have a totalizer. One virtual device that just holds the entire total.

    Then you will need a delta virtual device. Each time you turn on your fireplace, change that virtual device to ON. (Create an event that will also turn on the virtual device when you turn on your fireplace). When you turn off the fireplace, just have the below bunch of stuff happen as well as turn off the fireplace.

    Next shove hs.devicetimebyname("Living Room Fireplace") into a variable. This will be the amount of minutes that the device has been on.

    Then you will want to read in the value (which you will store in the first totalizer) and add in the value from the above step (my/Jon00's example code below shows this). Then replace the value of the totalizer with the new variable.

    Finally set the value of the virtual device to Off.

    I tried to give you help without solving your problem. This way maybe you can learn the scripting. It REALLY is the most powerful part of Homeseer.

    The devicetimebyname funtion (from the help file):

    "
    Purpose

    Returns the time in minutes since the device status last changed. This can be used to see how long a device has been ON or OFF."


    I posted my whole edited script (again, Jon00 was the originator so I give him the credit!) so you can run it and play around with it.

    --Dan

    "
    'Very simple script to update the world population on a virtual device, every time the script is run.
    '
    'Place this script in the Homeseer 2/scripts directory and the supplied gif in the Homeseer 2/HTML/Images directory.
    '
    'Also create a virtual device and call it world population. Set this to the Housecode you specify below.
    '
    'Just create an event to run this script (worldpop.vb) every X mins/hours (your choice!)
    '
    'Have fun!

    'Written by Jon00 jon00@btinternet.com
    '
    'The latest version can always be found at http://www.jon00.me.uk/hs.html
    '
    'V1.12 April 15th 2006
    '
    'VB.NET VERSION FOR HOMESEER 2 ONLY


    sub Main(parm as object)

    Dim Housecode as string
    Dim Worldpop as string
    Dim WorldpopChangeCode as string
    Dim WorldpopNumberCode as string
    Dim delta

    ' ***** Set Housecode here! *****

    WorldPopNumberCode="q97"
    WorldPopChangeCode="q98"
    Housecode="q99"

    ' *******************************

    Worldpop=hs.GetURL("http://www.census.gov","/cgi-bin/ipc/popclockw",false,80)
    Worldpop=replace (Worldpop,chr(34),"",1,-1,0)
    Worldpop=hs.StringItem(Worldpop,2,"<div id=worldnumber>")
    Worldpop=hs.StringItem(Worldpop,1,"</div>")
    delta = worldpop - hs.devicestring(WorldPopNumberCode)
    hs.setdevicestring (Housecode,"<img src='/images/world.gif'> World Population: " & Worldpop,true)
    hs.setdevicestring (WorldPopNumberCode,Worldpop, true)
    hs.setdevicestring (WorldPopChangeCode, delta, true)

    end sub

    "
    Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

    Comment

    Working...
    X