# kWh/hour feed

I watched the How to create a feed with kWh/hr? thread started by @OlavKristiansen with interest because I wanted to create a daily feed with instantaneous values to represent state of charge for my home battery. It’s a bit tricky to get it right so I wanted to reset it each day and then it’s close enough. I can see the answer is usually to use the delta in graphs solution but that doesn’t work for me.

With my limited understanding of emoncms (I’ve been using it for 5 years but I wouldn’t call myself an expert), for kWh feeds I always use Power to kWh, which adds a Watts amount to a cumulative feed.

Through experimentation I discovered that if, for one of these kWh feeds, you “Log to feed” a specific value, it will set the feed to this. So what I did was to set up a schedule for 23:59 each day (the schedule value is simply “23:59”) and on this schedule, Log the value zero to the feed. It works, but obviously during that one minute, I’m losing the Power to kWh values but I don’t care because the battery is always empty (in the winter at least!).

So, how to set up the kWh/hour feed?
I’ll tell you but there are 2 caveats:

• You lose data for one minute of each hour (if you need 100% for history then use a second feed)
• If zero is a legitimate incremental amount this may not work for you as zero triggers zeroising of the feed value (would be nice to use something which can’t happen such as -1 but I can’t see how to do that with the current available processes)

If those caveats work for you, create a schedule with the following expression:
`00:59,01:59,02:59,03:59,04:59,05:59,06:59,07:59,08:59,09:59,10:59,11:59,12:59,13:59,14:59,15:59,16:59,17:59,18:59,19:59,20:59,21:59,22:59,23:59`

The following is my input processes for my heat pump power. Steps 1 & 2 were there already so I added steps 3-6 to set up the hourly kWh/hour feed. I don’t specifically need this myself but did it as an example to show you all.
Step 3 is a standard Power to kWh to take the current W value and add it to the cumulative “hourlykwh” feed.
Step 4 says "If it’s a time in the “EachHour” schedule, set the current value to ZERO.
Step 5 says “if the current value is not zero, don’t do step 6”
Step 6 does the Log to feed of the zero value to the “hourlykwh” feed.

So what does my “hourlykwh” feed look like?

Flame-proof suit on… Create Topic!

2 Likes

Thanks for sharing @christian that looks good and a interesting solution, Im sure @nchaveiro will be pleased with the way that you have used the schedule module here.