Forward 'custom' node to emoncms.org

Hi - I have a couple of remote temperature sensors transmitting to a receiver on my raspberry pi, and I have successfully forwarded these inputs to emoncms.org

I have also created a pseudo node using the input api in emoncms, which I post values to from a program running on my raspberry pi. However, this node is not showing up in emoncms. Is there any way in which I can get these values forwarded to emoncms as well please?

Thanks for any help.

Jérôme's picture

Re: Forward 'custom' node to emoncms.org

I'm afraid the simplest way is to modify your program to post to both local and remote emoncms.

engeeaitch's picture

Re: Forward 'custom' node to emoncms.org

Thanks for the reply.  My concern with doing this is that it will slow down my program - especially if there is some problem with the internet whilst posting to emoncms.org. Do you have any pointers as to how to do this as part of the other feeds?  I am happy to play about with changing php code files.

Jérôme's picture

Re: Forward 'custom' node to emoncms.org

I remember another message on this forum (or on github) from someone who wanted remote forwarding in emonCMS so that he could use a Nanode (if I remember well) to post to emonCMS locally and have local emonCMS forward the data.

AFAIU, current design follows the opposite logic, leaving it up to the application to send the data to any number of emonCMS instances.

I think the reason for this is that historically people would use a Nanode or such and necessarily post to a remote emonCMS. Then came the Pi and the possibility to host a local instance, and it was assumed that the data would come through the RFM2Pi from emonTX nodes.

Implementing the forwarding feature in emonCMS may be a complicated task, depending on how confident you are with php. You may want to raise this issue on github as it is a long time design choice. Perhaps Trystan would be interested. But don't expect this to be done soon.

Meanwhile, I'm thinking of another way.

It shouldn't be too difficult to modify both your application and the python gateway script to do what you want (this is the pythonist speaking, here). Say you create a file that would act as a FIFO buffer. You application writes a line in the file instead of sending to emonCMS. Then it's just a matter of reading the file from the python script just as we would read the COM port, sending to local and remote emonCMS. I can help with the python part. I think we can reuse a great part of the code. Not much more to create. (This is me being optimistic. Sunny day, good mood.)

Perhaps someone else with come up with a better answer.

engeeaitch's picture

Re: Forward 'custom' node to emoncms.org

Hi - I am happy to help with this (but I don't know python).  Do you simply mean append a line to a file, or is there something more complicated that you had in mind?

Jérôme's picture

Re: Forward 'custom' node to emoncms.org

When received through the RF, the data is read by the script through the serial port with the following form:

  10 132 6

where 10 is the node ID and the trailing values are the data.

If your software appended the samples this way in a file, I don't think it would take much work to adapt the python (or php) script to use them.

What language is your software written with ?

I believe I could add an option in the script to parse a file. It would be generic enough to be worth doing (not specific to your case).

 

engeeaitch's picture

Re: Forward 'custom' node to emoncms.org

Hi - sounds great.  I think I could do this easily enough (but not quite sure what the data values are - I am currently sending a json string of the form input/post?json={boiler:1} .  'boiler' is the name I have given to the node, and 1 (or 0) is the value.  My script is written in PHP.

Jérôme's picture

Re: Forward 'custom' node to emoncms.org

A shortcoming of the python (and the php) gateway script, is that it can't send an input name (such as 'boiler'), just values.

(The node sends values like this other RF: 10 123 45 43 65 and the gateways knows it means NodeID 10 and values "123 45" and "43 65". There is actually a little bit of coding here, as these are not the values themselves. Signed long are encoded as two unsigned shorts.

The values must be recombined: 123 45 -> 123 * 256 + 45, then if > 32768, substract 65536.

We have a choice, for the format of the buffer file. Either use the same coding, or write values the natural way. Former means more calculation, just for the sake of keeping the same format. Not sure it is useful. We could go for the natural way... and break that if we realize later on it was not the best choice.)

The name is not absolutely needed, rather practical. An input will be created for your virtual node with ID "1" and you'll make a feed called "boiler" where you'll log this input.

This means each call (each line in the file) must contain all values, all in the same order.

I'd like to introduce a rework in the next version, offering the ability to set names to the inputs. This is a bit of an issue because the python gateway uses the "bulk" syntax to send values remotely: http://openenergymonitor.org/emon/node/2249. The idea was to be able to send several samples in one request, but this itself may not be necessary. Even one http request every 3 seconds is not a big deal. Also, there is no way to tell the gateway which name corresponds to which RF received value. That's a few things to think about before starting implementing.

I haven't thought of it too much, I may be missing the obvious. I'm just thinking out loud, as I wanted to answer your specific question.

Bottom line, if you write the file this way:

12 1
12 0

where I set 12 as an arbitrary node ID and 1 or 0 are the values, then it shouldn't be too hard to adapt the gateway script to send that locally and remotely, in a fashion that would let that feature be as generic as possible.

The rest is future and I need to re-think it.

Perhaps a totally different approach implying the creation of an input processor that would forward the data is a better approach...

Comment viewing options

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