Bulk data upload to EmonCMS (Agile Octopus) but graph times are off?

Regards the “supplementary question”, that is just where the times/intervals used in the graphing query are independent of the data being queried. If you look at the values used in the graphs query directly below the graph, they can be altered to almost any interval and start/end times you like (within the size/pixel restrictions of the graph area) so you could change the start time to a multiple of 1800 and the interval to 1800 and get the graph you expect.

With regard to having absolute control of the recorded timestamps, there are 2 main element to this.

First, the only way to be sure of avoiding the timestamps you provide being “adjusted” is to use a “time=0” parameter in the bulk upload api (rather than sentat= or offset=). The other methods use it’s own server time to “adjust” the supplied timestamps and can introduce errors if there is any network delays or differences in the times between the 2 devices.

This is discussed in the Best way to guarantee times when using BULK load with PHPTIMESERIES? - #2 by pb66 thread and other forum discussions can be found by searching “data=0”. Unfortunately most of the links I made in that discussion are no longer right as the code has been refactored and moved to emoncms/Modules/input/input_methods.php but still works the same way.

The next part is once you have reliable “absolute” timestamps being used in the input stages, you need those datapoints to be saved to the right time slot in a fixed-interval feed. The slots all start at multiples of the interval from the start time. Therefore if your feed is 60s and commissioned at 10s past the top of the minute, every slot will start at 10s past the top of the minute. So if you data is presented with an absolute timestamp that happens to be 7s past the top of the minute, it will be 3s short of being out in the next slot and placed in the previous slot, effectively removing 57secs from the timestamp as the slot position relative to the feed start time IS the timestamp from here on.

Luckily, this latter point is easily managed if you sort the absolute timestamps in the requests before creating the new feeds because regardless of when you actually create the feeds, the start time is the timestamp of the first saved data. Unfortunately it is not possible to change the start time once a feed is first used.

Where are the timestamps originating from? are they read from the Agile website or are you just querying that site every 18000 secs? Are the 1800s intervals anchored in time somehow or just “every 1800s”?