Extending emonhub interfacers

Hi all.

I am looking to make a simple new interfacer for emonhub with a external embedded device.
So basically, each time data is received over the serial, I want to forward this data over a TCP connection.
Any documentation or suggestions on how the interfacers are structured in emonhub?

Cheers and thanks!

There isn’t really any documentation on creating emonhub interfacers.

You should start by looking at the relationship between the RFM2Pi interfacer and the serial interfacer. The serial interfacer is intended to be fairly generic and the idea is you inherit from that to create new serial based bespoke interfacers.

Since the emonpi variant was spread out into separate files the import statements have gotten a bit out of control, for a more basic glimpse of how the classes work without the complexity of the imports and modules, take a look at the original version where the interfacers are in one file

I will give you some assistance if I can. What are the characteristics of your device? Is it polled? does it just broadcast periodically? Does it need 2 way comms? Do you need to configure it via emonhub?

Hi Paul.

So in my use case, I had to modify the RFM2pi interfacer to read/write some additional commands, its ugly, but it works.
Data is sent periodically over the serial, and then forwarded per usual via the emoncms interface.
I need this new interface to just forward the data (TPC/IP, very much same as emoncms interface), but without any processing and frames. I definitely need to configure it via the emonhub config file [require IP and PORT variables].
I don’t think 2 way comms are required right now.

It sounds like it’s a http interfacer you need to write then.

The serial or rfm2pi interfacer will just decode the serial data to get the node id and actual real values etc and that is passed to the emoncms http or mqtt interfacers without a format, the out going format is determined by the outgoing interfacer.

Also if you want to run this in parrallel to a standard emon system you can change the pubchannels and subchannels so that your custom serial interfacer sends it’s data to just your bespoke http interfacer without any cross posting, effectively 2 separate systems within one emonhub instance.