Re: Virtual device for usage last day/week/month
Posted: Mon Apr 01, 2013 12:08 am
Even if you don't use this, perhaps it will help to give you an insight into scripting with Homeseer.
I have attached a zip file containing a vb script and an ini file.
Please Note: This is not fully tested but it is based on a script used in my system.
I have purposely left out error checking (apart from 1 try catch as an example) to make the code clearer and I have only added the day and week devices so perhaps you could add the month and year devices yourself.
The ini file needs to go into your /homeseer/config folder and the script into your /homeseer/scripts folder.
You will need to edit the first few lines of the script as I have assumed that the main meter device is Q3 and that Today, Yesterday, This Week and Last Week will be devices A1, A2, A3 and A4.
You can run the "UpdateValues" function from a Homeseer event at any time and all relevant devices will be updated.
If you run the "ResetCounters" function from a Homeseer event between 00:00:00 and 00:01:00 the devices will be updated, so yesterday's device becomes today's value and today's device value becomes 0. If it is Monday then the last week's value becomes this weeks etc...
Paul..
I have attached a zip file containing a vb script and an ini file.
Please Note: This is not fully tested but it is based on a script used in my system.
I have purposely left out error checking (apart from 1 try catch as an example) to make the code clearer and I have only added the day and week devices so perhaps you could add the month and year devices yourself.
The ini file needs to go into your /homeseer/config folder and the script into your /homeseer/scripts folder.
You will need to edit the first few lines of the script as I have assumed that the main meter device is Q3 and that Today, Yesterday, This Week and Last Week will be devices A1, A2, A3 and A4.
You can run the "UpdateValues" function from a Homeseer event at any time and all relevant devices will be updated.
If you run the "ResetCounters" function from a Homeseer event between 00:00:00 and 00:01:00 the devices will be updated, so yesterday's device becomes today's value and today's device value becomes 0. If it is Monday then the last week's value becomes this weeks etc...
Paul..