Support for emonCMS / Similar to Domoticz HTTP

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
fluppie
Normal user
Posts: 89
Joined: 09 Oct 2015, 13:23

Support for emonCMS / Similar to Domoticz HTTP

#1 Post by fluppie » 09 Oct 2015, 23:13

Hi,

Do you think it would be hard to modify the Domoticz code to have support for emonCMS?
I think the "node" from emonCMS is similar to the "idx" from Domoticz.

If you go to http://www.emoncms.org and login with username esp8266nu & password esp8266nu
There you can read the API on: http://emoncms.org/input/api

Code: Select all

Input API
Apikey authentication

If you want to call any of the following actions when your not logged in, add an apikey to the URL of your request: &apikey=APIKEY.

Read only:

Read & Write:
Available HTML URLs
The input list view	http://emoncms.org/input/node
This page	http://emoncms.org/input/api
Input processing configuration page	http://emoncms.org/input/process?inputid=1
Available JSON commands

To use the json api the request url needs to include .json

Post data
JSON format:	http://emoncms.org/input/post.json?json={power:200}
CSV format:	http://emoncms.org/input/post.json?csv=100,200,300
Assign inputs to a node group	http://emoncms.org/input/post.json?node=1&csv=100,200,300
Set the input entry time manually	http://emoncms.org/input/post.json?time=1444424907&node=1&csv=100,200,300

APIKEY
To post data from a remote device you will need to include in the request url your write apikey. This give your device write access to your emoncms account, allowing it to post data.
For example using the first json type request above just add the apikey to the end like this:	http://emoncms.org/input/post.json?json={power:200}&apikey=ef612d3deee58fbed7cdde3933dd8759

Bulk data
You can provide data using bulk mode	http://emoncms.org/input/bulk.json?data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]]

    The first number of each node is the time offset (see below).
    The second number is the node id, this is the unique identifer for the wireless node.
    All the numbers after the first two are data values. The second node here (node 17) has two data values: 1437 and 3164.
    Optional offset and time parameters allow the sender to set the time reference for the packets. If none is specified, it is assumed that the last packet just arrived. The time for the other packets is then calculated accordingly.

Legacy default format (4 is now, 2 is -2 seconds and 0 is -4 seconds to now):	http://emoncms.org/input/bulk.json?data=[[0,16,1137],[2,17,1437,3164],[4,19,1412,3077]]
Time offset format (-6 is -16 seconds to now):	http://emoncms.org/input/bulk.json?data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&offset=-10
Sentat format: (useful for sending as positive increasing time index)	http://emoncms.org/input/bulk.json?data=[[520,16,1137],[530,17,1437,3164],[535,19,1412,3077]]&sentat=543
Absolute time format (-6 is 1387730121 seconds since 1970-01-01 00:00:00 UTC))	http://emoncms.org/input/bulk.json?data=[[-10,16,1137],[-8,17,1437,3164],[-6,19,1412,3077]]&time=1444424907

Input actions
List of inputs	http://emoncms.org/input/list.json
Delete an input	http://emoncms.org/input/delete.json?id=1

Input process actions
Add an input process	http://emoncms.org/input/process/add.json?inputid=1&processid=1&arg=-1&newfeedname=power
List input process list	http://emoncms.org/input/process/list.json?inputid=1
Delete input process	http://emoncms.org/input/process/delete.json?inputid=1&processid=1
Move input process	http://emoncms.org/input/process/move.json?inputid=1&processid=1&moveby=1
Reset input process list	http://emoncms.org/input/process/reset.json?inputid=1
Powered by openenergymonitor.org | v8.3.5 
It is a popular CMS used by the openenergymonitor community.

rmtucker
Normal user
Posts: 57
Joined: 04 Oct 2015, 17:14

Re: Support for emonCMS / Similar to Domoticz HTTP

#2 Post by rmtucker » 10 Oct 2015, 04:52

I have already added a controller for emoncms for my own use.
If i clean the code up a little i will post it here.
It took me a while to get it to work before i realised that the webserver is truncating the controller password to 26 chars.
Emoncms apikeys are about 34 chars or something.
It has been posting to emoncms for approx 36hrs now so seems stable.

rmtucker
Normal user
Posts: 57
Joined: 04 Oct 2015, 17:14

Re: Support for emonCMS / Similar to Domoticz HTTP

#3 Post by rmtucker » 10 Oct 2015, 20:29

I have committed the changes too add emoncms as a controller.
It still needs a little work though.
Fingers crossed.

fluppie
Normal user
Posts: 89
Joined: 09 Oct 2015, 13:23

Re: Support for emonCMS / Similar to Domoticz HTTP

#4 Post by fluppie » 12 Oct 2015, 07:39

Working fine! Thanks a lot :).
http://emoncms.org/Schilde/espeasy

fluppie
Normal user
Posts: 89
Joined: 09 Oct 2015, 13:23

Re: Support for emonCMS / Similar to Domoticz HTTP

#5 Post by fluppie » 19 Oct 2015, 16:51

It works pretty well, only weird when you connect a second sensor:
emonCMS.png
emonCMS.png (22.42 KiB) Viewed 9797 times
Do you call by accident the post URL 1 time per connected sensor? Not a bulk data "post" URL for everything?

rmtucker
Normal user
Posts: 57
Joined: 04 Oct 2015, 17:14

Re: Support for emonCMS / Similar to Domoticz HTTP

#6 Post by rmtucker » 20 Oct 2015, 11:30

I can not see anything wrong in the screen shot?
I presume you have 2 nodes with 3 sensors attached to each?

fluppie
Normal user
Posts: 89
Joined: 09 Oct 2015, 13:23

Re: Support for emonCMS / Similar to Domoticz HTTP

#7 Post by fluppie » 20 Oct 2015, 19:30

The delay/last updated isn't the same. So I think sometimes an URL fails to post. Does it call 2 times the JSON url?
I have 2 sensors (DS18B20 and BMP085) per node.

rmtucker
Normal user
Posts: 57
Joined: 04 Oct 2015, 17:14

Re: Support for emonCMS / Similar to Domoticz HTTP

#8 Post by rmtucker » 20 Oct 2015, 20:12

Yes it posts seperately to the api for each Task.
I have noticed a massive problem with emoncms recently dropping updates,very Flakey (even though the response is "ok" after the status update.)
For this reason i have set up my own local server with domoticz and a raspberry pi.
You could also change the message delay in Tools Advanced because emoncms might be rate limiting.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest