There’s something I really want on my dashboards… That is, how many kWh I’ve consumed today (and possibly this month and this year) so far. Currently that’s not possible with the incrementing kWh feeds.
I had a thought that it might be nice to add today, start of month and start of year values to the feed object returned from the feed list API.
The biggest question is should this be on the list endpoint or a separate endpoint? I’m sort of veering towards a separate endpoint to keep it clean. But it would mean another call per feed, or one batched up one if we did that.
I’m not quite sure on the style of how the API is structured just yet, so looking for opinions.
I too would like the functionality you suggest to provide daily, weekly to date, month to date and year to date values.
I also have a need to provide “since a set point” urls, This was mentioned in the “Emoncms daily, weekly, monthly kWh and averaging” thread on the old forum It’s no longer essential but I would still find it handy.
I now wonder if it would be possible to use default values to extend the existing feed api urls to handle more scenarios by including or omitting the start time and/or the end time. eg
if the end time is excluded then “now” is used, this allows for incrementing totals from any fixed point in time eg since PV installed etc.
if the start time is excluded then “beginning of this period” is used and “this period” is defined by the daily/weekly/monthly/yearly setting. Unless a “period=7days” was used in which case you would get the full “rolling” 7 days up to “now” instead of the total since the beginning of this week which maybe only a day or 2.
The use of negative periods eg “period=-7days” (an alternative to mode=weekly?) could also allow both a “previous week” and a “current week”, either as rolling intervals (last 7days and previous 7 days) or as fixed periods (this week to date and last weeks total).
That’s a nice approach. I think the end time omission would be useful in any case. A lot of requests will simply have “now” as the end time, and so a nice optimisation is not having to send this.
What API are you thinking of this on, data.json? The thing there is that you need to specify an interval, or a mode.
I’m actually wondering if things are at crossed wires right now. I have a feeling I might be misunderstanding now I come to think about it! With that in mind, how about this as a proposal:
New endpoint called delta.json.
Takes the following parameters:
One of the following is required:
id - The ID of the feed to request the data for.
ids - A comma separated list of the IDs of the feeds to request the data for.
One of the following is required:
start - A timestamp of when you want to calculate from.
startoffset - Either day for start of today, month for start of the current month, year for start of the current year.
end - (optional) A timestamp of when you want to calculate to. If omitted, latest feed value is assumed.
Returns timestamp of the start time (incase you used startoffset and want to know when the data is actually for) and the difference of the value between that time and end.
I also would be interested in units used this week and total units used last week and the same for month data.
That way it can be easier to identify trends on energy usage.
Sadly not. I have some commits on the dashboard and the emoncms forks of mine that enable the behaviour. But it’s not really the right way of doing it for pushing upstream.