How to - read EmonPI / Nodes module API?

Hi all,

I have done a search and can't find a clear answer to my question. I have just purchased a EmonPI and would like my existing home-automation system to be able to read the real-time consumption feed.

In the API documentation I see that I can GET http://emonpi/emoncms/nodes/5/rx/1 and return a JSON object in the form :

{"name":"power1","value":"100","unit":"W"}

But this only works if I am logged in and have an existing authenticated session. I therefore assume I need to add my read API key but I can't determine the syntax to do this. Can someone help or point me at a wiki / doc?

Many thanks

Paul
 

 

Paul Reed's picture

Re: How to - read EmonPI / Nodes module API?

If you look at your 'Feed API Help' link on your feeds page, it will give you details of how to format your API syntax.

To authenticate, add &apikey=YOURAPIKEY to the URL.

eg

http://yourdomain.co.uk/emoncms/feed/value.json?id=13&apikey=c76354Fggdf...

 

Paul

Paul-B's picture

Re: How to - read EmonPI / Nodes module API?

Paul,

Thanks for the info. I wanted to use Nodes rather than Feeds although I could re-write to a feed. My limited understanding is the API in Feeds is part of the core code, whilst the API for Nodes has been added as part of EmonView. If I try to add apikey=MyAPIReadKey for a node query it doesn't work so I assume it needs to be in a different syntax?

Paul

 

 

TrystanLea's picture

Re: How to - read EmonPI / Nodes module API?

Hello Paul, can your home automation system subscribe to MQTT messages? that might be a better approach if you have the option. Before the data gets into the emoncms nodes interface it is first read from the emonpi serial port using emonhub, this then forwards the data on to the local emoncms using MQTT and it can also forward the data to a remote emoncms such as emoncms.org via HTTP.

We are actually moving away from the nodes interface in the next emonpi image update (https://openenergymonitor.org/emon/node/12437) - to the input module with the node data posted there from emonhub via mqtt. So perhaps if your going to setup something more complex you might be interested in downloading the pre-release image there.

Third option, I've found the bug in the emoncms nodes module and have fixed it, If you run the emonpi update tool it will bring in the latest changes. You will then be able to access to read values with the api:

http://emonpi/emoncms/nodes/5/rx/1?apikey=READ_APIKEY

PS the nodes module is different from emonview which was an experimental attempt to create a simplified python implementation of emoncms which has been discontinued for now. To avoid confusion I will change EmonView to Nodes module in the subject line.

Paul-B's picture

Re: How to - read EmonPI / Nodes module API?

Trystan,

Thanks for the quick fix and explanation. I have updated my EmonPi and can now access the Nodes module. I'll use this for now whilst I explore and discuss moving to MQTT with the home automation vendor. Appreciate the explanation and help as I get up to speed with the whole ecosystem

Paul

 

 

Comment viewing options

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