Reset a feed daily

Hi
I have a CT input providing a kWh feed, but I would like a copy which resets to zero each day (eg midnight). So I can see the daily structure of the input (IE not kWh/d which only seems to give the cumulative total per day)
I am sure this should be easy, but just can’t find how to do it
Thanks
Kevin

Welcome, @octoplayer2 to the OEM forum.

Take a look at the Inputs process “Max daily value” (under the sub-heading Misc). If you send the result of this to a new feed (you can only have a variable interval one - so this records the time the value was written), I think it could be what you want. I haven’t tried it, so I can’t say that it is.

Hi Robert, thanks for the suggestion; I have just tried it, but it only creates one value per day, updating that if the new input is larger.
Kevin

The emoncms API allows for a feed data point to be updated or a new one inserted.
Eg. http://192.168.11.200/feed/post.json?id=2&time=0&value=100&apikey=xxxxxxxx
See the Feed API help link on the Feeds Tab for details.
To achieve what you are asking about on my system I would setup a power to kWh input process from your CT input to accumulate the daily energy profiles into a new feed. I would then set up a regular task to post a zero value to the feed at midnight each day. I use node-red to do a lot of stuff like this alongside emoncms.

What about “If schedule, zero” and the schedule spans a reading around midnight. It depends on data coming in which it can convert to zero while the Schedule is active, and you’ve got to watch that you don’t use Wh Accumulator or kWh Accumulator, both ignore the reset to zero!

Thanks, I looked at this option but it means accessing cron, so setting up ssh, and having to edit the job every time I want to change. I also thought about a batch file running on my Windows server, but its another step to go wrong.
owever, cron may end up easier to support than the convoluted script I am testing. :slight_smile:

Thanks - that’s the line I have followed although it ended up a lot kludgier than I had hoped for what I thought was a simple task.
In case it helps other users, or it can be simplified, I have attached a screen shot of the input steps:
1 Correction factor for my ct clamp
2 if null, (rather than if zero in case I got a genuine 0.0 reading)
6 I found I needed a couple of lines to zero the accumulator, so used a hop skip and jump
7 Set the value to 0
8 and subtract the total
9 then add it back to the feed, setting the feed to zero
10 recover the input vale, multiply it by my 0.22 calibration, and 10s / 3600s to convert my Watts at 10s sample rate to Wh,

Suggestions welcome, I have some more testing to do, and might try converting to use the builtin kwh accumulator, but I dont think it saves any steps. :woozy_face:

I agree, that does look rather more complicated than I anticipated. It may well be that what you have is the simplest - some things that should be trivial if you were writing the raw code turn out not to be, simply because the need was never anticipated.