kWh/d (realtime)

Hi!

I’m trying to create a realtime kWh graph which accumulates on daily bases.

Power to kWh/d only create a Daily feed, but I want to see a growing graph according with kWh, then, on midnight it resets to 0.

Any idea?

Thanks.

1 Like

This is not possible “out of the box” but it can be done if you are willing to set up an input triggered from a cron job.

Feeds can be manipulated in multiple input process lists, if you are careful and clear about what you are doing.

Lets say you have an emonPi input “power1” for which you create a feed for called “daily_kwh_slope” that gets updated through a power to kwh process in power1’s processlist. So far very normal.

You then use an input api call like so (using your write apikey)

https://emonpi/emoncms/input/post?node=resets&csv=0&apikey=1234abcd

to create another input called “resets” in that inputs processing you can add a “log to feed” process and select your “daily_kwh_slope” feed.

You now have 2 inputs updating the same feed, the emonpi power1 input is regularly incrementing with power values and the “resets” input zeros it when ever it is called, now all you need is to call that api at midnight each day using a cron job, using either wget or curl.

One possible hurdle with this is phpfina (fixed interval) feeds, if you use phpfina, you will need so pretty complex timing to make sure the reset sticks, you are much better off using phptimeseries if you are attempting this and want an easier life.

@pb66

Thanks for reply!!
I’m almost do it direct in database (create a job to reset it on DB - lol), you give me a better way :smiley:
I already have a node inputing data through api, I’ll try this way. :smiley:

Thanks again.

Thanks for the nice trick!

One small modification:
https://emonpi/emoncms/input/post?node=resets&csv=0&apikey=1234abcd
This gives me error: “:.contains no data via csv…”

Therefore it has to be:
https://emonpi/emoncms/input/post?node=resets&csv=0.0&apikey=1234abcd

Regards, Timo

Hmmm, mine worked with csv=0 using:
curl -s --data “node=resets&csv=0&apikey=$APIKEY” “http://127.0.0.1/emoncms/input/post

@pb66

Thanks again, it really worked nice. Just need put it on cron at 00:00

Glad you both got it working, albeit slightly different results with the the CSV, I can’t explain offhand why that might be, I will take a look if I get a chance. But I suppose, strictly speaking, a single value cannot really be CSV (comma separated values) for it to be CSV I guess it should have at least two values and one comma.