Announcement

Collapse
No announcement yet.

How can I store month end values of a virtual device ?

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

    How can I store month end values of a virtual device ?

    I have 4 virtual devices, which add up times of my AC being on and other devices being on (I am using Jon00's uptime monitor for this). This is stored or displayed as days, hours, minutes and seconds in a virtual device. I would like to automatically grab all these values and store them somewhere, at the end of the month at midnight. It could be stored in another virtual device, or a variable, its not that important. I only want to be able to grab these values some time after the end of month to put them into a Excel spread sheet. (I can do this manually, unless there is a way of automating that too)
    Last edited by mikee123; September 2, 2016, 03:28 AM.

    #2
    I use a virtual device as a condition for my "last day of the month" events. I set the value of the virtual device using this script which runs per day shortly after midnight:

    Code:
    Sub Main(ByVal Parms As String)
    
    	Dim Debug As Boolean = True
    	Dim logType As String = "Last Day"
    	Dim myDate As Date = Now.Date
    	Dim myNewDate As Date = Now.Date
    	myNewDate = DateAdd("d",1,myDate)
    	If myDate.Month <> myNewDate.Month Then 'last day of the month
    		hs.setDeviceValue(6064, 100)
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(6064,true ,"Yes",true,false))
    	Else 'not the last day of the month
    		hs.setDeviceValue(6064, 0)
    		hs.CAPIControlHandler(hs.CAPIGetSingleControl(6064,true ,"No",true,false))
    	End If
    
    end sub
    To store the actual values, run a daily event with the status of the last day of the month device as a condition, and copy the values you want to save to other virtual devices, or use one of jon00's utilities to get them into a db for graphing. Here's a screen shot of the latter:

    Click image for larger version

Name:	Capture.jpg
Views:	1
Size:	54.6 KB
ID:	1186915

    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      That is exactly what I had in mind, graph it. I'll be looking at another of Jon00's plugins then... using quite a few already. Very useful. And I'll also be adopting your script, exactly what I need.

      Comment


        #4
        I thought HS already had a trigger that could do this, I've not tried it in practice though this is just a test to show (I appreciate you don't have the action, that is for a plugin I wrote).
        Last edited by mrhappy; December 28, 2016, 03:17 PM.

        Comment


          #5
          Originally posted by mrhappy View Post
          I thought HS already had a trigger that could do this, I've not tried it in practice though this is just a test to show (I appreciate you don't have the action, that is for a plugin I wrote).
          Thanks Adam, I had not noticed that condition before.

          Cheers
          Al
          HS 4.2.8.0: 2134 Devices 1252 Events
          Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

          Comment


            #6
            I will probably run both of your suggestions in parallel, that gives me best of both worlds. Haven't had a chance yet to install Jon00's plugin but it looks good so will get on it as soon as I have a chance.

            Comment


              #7
              Originally posted by mikee123 View Post
              I will probably run both of your suggestions in parallel, that gives me best of both worlds. Haven't had a chance yet to install Jon00's plugin but it looks good so will get on it as soon as I have a chance.
              FYI, the latest version of my DBCharting package has the ability to store the last and differential values (from the last reading) for 5min, 10min, 15 min, 30min, 1hr, 12hr, 1 day, 1 week and one month intervals. These are stored in an ini file so can be easily read for charting or other purposes.
              Jon

              Comment

              Working...
              X