Problems using emoncms feed api

(repost in separate thread according to Paul's hint)

Hello experts,

I do like the idea of EmonHub; thanks to all contributors! I started with the ReadyToGo image (08/13/2014) and made updates on /var/www/emoncms and /home/pi/emonhub via git pull and on the system itself via apt-get upgrade. After all configuration was done the system seems to run fine, I could access the web sites etc.I wanted to start with manually creating feeds via web API according to the feed API help and tried a PHPTIMESERIES feed:

http://192.168.178.9/emoncms/feed/create.json?name=Test2&datatype=1&engi...

with success followed by sending a first value via

http://192.168.178.9/emoncms/feed/insert.json?id=1&time=1416771807&value...

After that I could see the feed in the feed list with the initial value and it could also be queried:

http://192.168.178.9/emoncms/feed/data.json?id=1

returns

[[1416771807000,100]]

But after sending another value

http://192.168.178.9/emoncms/feed/insert.json?id=1&time=1416771907&value...

the new value was shown in the answer, but did not appear on the feed list and could not be queried.

Does anybody have an idea what is going wrong here?

I also tried PHPFINA feeds but with even less success: I could send values but not even the first value appeared; it was only shown in the feed list,but could not be queried and did not show up in a chart.

Both, the directories of /home/pi/data/phpfina and phptimeseries contained files after my actions.

Finally I tried to create a feed for MySQL (engine 5) and got back an error:

Notice: Undefined offset: 0 in /var/www/emoncms/Modules/feed/feed_model.php on line 98 Fatal error: Call to a member function create() on a non-object in /var/www/emoncms/Modules/feed/feed_model.php on line 98

After that I could not even see the previous feeds anymore; so obviously something went totally wrong ... ;-((

Any help would be very appreciated. Thanks a lot. And best regards

Arwed

​Post title changed from; 'issues with Feed API on EmonHub' to 'problems using emoncms feed api' as per pb66's post below.
Paul Reed - Moderator

pb66's picture

Re: Problems using emoncms feed api

Hi Arwed

Your use of the emoncms api's totally bypass emonhub altogether.

The " problems using emoncms feed api " ( could be a better title ) will probally be due to using the "low-write" version of emonCMS, you can only append data, you cannot insert or edit data. You can also only use certain data feed types (ie not sql). These measures are what makes it "low-write" and therefore able to be run on an SD card, if you need full emonCMS functionality you will need to install "full" emoncms to a HDD.

see https://github.com/emoncms/emoncms/blob/bufferedwrite/readme.md for more info on the "low-write" version of emoncms.

Paul

 

Post moved and edited by Paul Reed - Moderator

arwed's picture

Re: Problems using emoncms feed api

Paul answered in the other thread, that "... you can only append data, you cannot insert or edit data. You can also only use certain data feed types (ie not sql). These measures are what makes it "low-write" and therefore able to be run on an SD card ...".

What API function could be used for appending? Feed API help lists either insert or update. Do you have any suggestion? Reason why I'm asking is that I'm looking for an easy way to transfer old data from a MySQL based EmonCMS that was running for quite a long time to the freshly installed EmmonHub.

Many thanks for any help in advance ...

Arwed

 

Paul Reed's picture

Re: Problems using emoncms feed api

Paul answered in the other thread, that "... you can only append data, you cannot insert or edit data. You can also only use certain data feed types (ie not sql). These measures are what makes it "low-write" and therefore able to be run on an SD card ...".

Agreed, so why did you repost the exact same question?

Paul

pb66's picture

Re: Problems using emoncms feed api

Hi Arwed

What API function could be used for appending? Feed API help lists either insert or update. Do you have any suggestion?

When I say the data needs to be "appended" that is not a command or a function but a pointer to how the data needs to be delivered to a low-write emonCMS data feed, as in " data can not be inserted or edited it can only be added to the end of the existing data file ". I cannot tell you exactly how to do it because I haven't tried it but I think you should use the input API to input data. maybe something along the lines of

1. Use an input API URL string to automatically create an input matching the data format you need to import.

2. Create a feed to store data in the normal way by attaching it to an input.

3. use the "bulk" input API to send the data in batches of say 200, this will probably involve writing a script to loop through your sql or csv data.

4.once all the data is uploaded you can delete the input and move on to the next feed(s)

Reason why I'm asking is that I'm looking for an easy way to transfer old data from a MySQL based EmonCMS that was running for quite a long time to the freshly installed EmonHub.

There is no "easy way" I'm afraid ! and you cannot transfer data to emonHub, emonHub is just an interface for emonCMS you are totally bypassing emonHub by using emonCMS API's to input data directly into emonCMS.

If what you really want is to transfer your older SQL emonCMS data to a newer "low-write" version of emonCMS, which uses the later data storage methods. Maybe you should have started a thread " how to transfer old SQL data into new emonCMS install " or something similar. 

This is something that has been asked before but I don't think there is a common method yet, so you may be able to get some pointers by searching the forum for terms including "restoring" "uploading" "sql data" etc

Paul 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.