Ampm Posted June 21, 2010 Share Posted June 21, 2010 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 More sharing options...
AzeoTech Posted June 22, 2010 Share Posted June 22, 2010 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 More sharing options...
Ampm Posted June 23, 2010 Author Share Posted June 23, 2010 Thanks a lot works great Link to comment Share on other sites More sharing options...
Ampm Posted June 23, 2010 Author Share Posted June 23, 2010 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 More sharing options...
AzeoTech Posted June 24, 2010 Share Posted June 24, 2010 I guess I'm not sure what you are asking as I believe what I explained does that. If you display kwhHistory[0] it will show the total count for the last month, right before you cleared it. Link to comment Share on other sites More sharing options...
Ampm Posted June 24, 2010 Author Share Posted June 24, 2010 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 More sharing options...
AzeoTech Posted June 30, 2010 Share Posted June 30, 2010 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 More sharing options...
Ampm Posted June 30, 2010 Author Share Posted June 30, 2010 Thanks for your help i will give it a try Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.