Community
OpenEnergyMonitor

Community

Emoncms feed API


(franck102) #1

Hi all,

I am trying to use the feed API to update a single (bogus) feed data point:

1546778700, 0.9
1546779600, 0.6
1546780500, 1.0

I have tried both GET and POST using curl, both calls return a 200 OK however the data point is not updated in the Graph view (show CSV output)… am I missing something?
I have double checked the feed ID; it is a Wh accumulator feed if that makes a difference.

Thanks!

curl -v -X POST "http://emonpi/emoncms/feed/insert.json?id=13&time=1546779600&value=0.9&apikey=<my write API key>"
*   Trying 2a01:cb15:81c2:e500:b10d:4809:3e2d:c9bf...
* TCP_NODELAY set
* Connected to emonpi (2a01:cb15:81c2:e500:b10d:4809:3e2d:c9bf) port 80 (#0)
> POST /emoncms/feed/insert.json?id=13&time=1546779600&value=0.9&apikey=... HTTP/1.1
> Host: emonpi
> User-Agent: curl/7.63.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sun, 06 Jan 2019 16:58:59 GMT
< Server: Apache/2.4.25 (Raspbian)
< Content-Length: 3
< Content-Type: application/json
<
0.9* Connection #0 to host emonpi left intact

C:\Users\Franck>curl -v "http://emonpi/emoncms/feed/insert.json?id=13&time=1546779600&value=0.9&apikey=<key>"
*   Trying 2a01:cb15:81c2:e500:b10d:4809:3e2d:c9bf...
* TCP_NODELAY set
* Connected to emonpi (2a01:cb15:81c2:e500:b10d:4809:3e2d:c9bf) port 80 (#0)
> GET /emoncms/feed/insert.json?id=13&time=1546779600&value=0.9&apikey=<key> HTTP/1.1
> Host: emonpi
> User-Agent: curl/7.63.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sun, 06 Jan 2019 17:00:32 GMT
< Server: Apache/2.4.25 (Raspbian)
< Content-Length: 3
< Content-Type: application/json
<
0.9* Connection #0 to host emonpi left intact

(franck102) #2

Oops, if I replace insert.json with update.json (I was using the wrong url) something does happen… but not quite what I expected, a new value is appended to the feed with a bogus unix time:

curl -v "http://emonpi/emoncms/feed/update.json?id=13&time=1546779600&value=0.9&apikey=<key>

1546794000, 0.9

The value at 1546779600 is left unchanged??

Franck


(franck102) #3

Answering my own question… I was naively taking the unix time values from the “show CSV output” on the Graph tab.
If I export the feed instead and use the unix times found there to update the bogus values the API works like a charm.

Franck