I was thinking that this is a pretty good trick for HB and so was going to write one but wanted to ask you guys first - what is the best way to get the on-times for various devices in HB. if you have constant loads like lights then it would be easy math to convert on-times into power used and money spent on each device per day. I see the following options for pulling the data:
1. Have each device you want to monitor write to a log file and then parse that
2. Once/minute check the power status of each property you wan to monitor and log that to a db/file/property/array/etc...
3. Read the HB db directly looking for status changes once/minute and log from that.
I guess I'm leaning toward #2 but are there any other ideas? If not which one of the above seems to be the best fit?
I was thinking that whatever I write would just return raw data so that the end user could use it for a web report, swremote display, graph, whatever...
What's in my mind at the moment is based on #2 above and would be similar to this :
*************************************************
(Setup)
Create a "monitor" script device with an alphalist property where each line is formatted as:
Device.Property to monitor, property state to monitor
example: Post Lamp.Power State, On
(Pseudo code)
Code: Select all
once/minute
for each device.property in alphalist:
if the current state = monitored state then
add one minute to the variable representing the total time for that device.property
once/day (midnight ??)
store in db (sqllite, access, flat-text) --> device, property, datestamp, totaltime
It would be cool if each device already kept up with it's on/off duration somewhere, perhaps a feature request if there is sufficient interest...
What are your thoughts, is it worth writing? It seems to be a simple endeavor...
TIA,
Terry