display history


Ampm

Recommended Posts

Hi i'm reading an energy meter and the Kwh channel is a basic running total which can be reset back to zero, i would like to reset this channel monthly and still display the last months total any ideas?

Link to comment
Share on other sites

You want to capture the last months total before you reset? Create a Test channel with Timing = 0 and Persist = 3600 (so the total is kept), then right before you reset the kwh channel, put the value into this test channel:

kwhHistory.addValue(kwh[0])

where kwhHistory is your test channel.

Link to comment
Share on other sites

That works fine thanks but ideally i would like to clear the counter at the beggining of every month and display the end of the previous months total reading automatically with some script any help would be appreciated thanks.

Link to comment
Share on other sites

Sorry for being a pain I can't be explaining myself very well, I would like to know how to write a piece of script to clear the energy meter on the first of every month without me having to do it manually, in which I can also add the line you gave previously to display last months total.

Link to comment
Share on other sites

OK, that makes sense and there are other forum posts that talk about doing things at months end, so I'll just paraphrase: use the formatdateTime() function in a channel Event for your counter. Use the time from the current reading and the last reading. It will be something like this:

if (formatdatetime("%m", mychannel.time[0]) != formatdatetime("%m", mychannel.time[1]))
   // clear counter, end of month
endif

It might be %M, I'm doing this off the cuff. You can look in the help under FormatDateTime() and it'll give you all the options.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.