Interfacer Questions - pub/subchannels

I’m running an emonTx serially direct connected to an RPi3 with NO radio transceiver.

Q1 - Is it OK/even desirable for me to delete the EmonHubJeeInterfacer?

Q2 - Re [[[runtimesettings]]] …

EmonHubJeeInterfacer has …
pubchannels = ToEmonCMS,
subchannels = ToRFM12,

Mqtt Interfacer is the other way around …
pubchannels = ToRFM12,
subchannels = ToEmonCMS,

Serial Interfacer which I am using only has …
pubchannels = ToEmonCMS … with no trailing ‘,’

EmonHubEmoncmsHTTPInterfacer is the same as the Mqtt Interfacer …
pubchannels = ToRFM12,
subchannels = ToEmonCMS,

A – Is the pub/subchannels sequence important? And why?

B – As I have NO radio transceiver, should I only be using for all Interfacers
pubchannels = ToEmonCMS ?
Trailing ‘,’ ?

Thx for any advice

Pls ignore this post - my problem is solved …
The solution is …
‘Go with the flow’ = the available OEM documentation
AND - add that all important trailing ','

1 Like

@pb66, @TrystanLea, @Robert.Wall, I’ve looked for anything in the documentation to explain the pub/sub channels and not found anything.

Can someone explain how this pub/sub channel works please? It is doing my head in trying to understand it :smile:.

Sure, if we take EmonHubJeeInterfacer as an example it reads data from the serial port and then pushes the data that it has read onto the pubchannel topic name ‘ToEmonCMS’.

The EmonHubEmoncmsHTTPInterfacer is subscribed to the pubchannel topic name ‘ToEmonCMS’ and so receives the data pushed onto that channel by the EmonHubJeeInterfacer.

EmonHubEmoncmsHTTPInterfacer then sends the data to emoncms via a HTTP request.


The name of the channel does not really matter ToEmonCMS could just be called channel A. Its very similar to say using redis rpush topic_name and lpop topic_name. The channels in emonhub are message queues.

Does that make sense?

I think I see. Every named ‘pubChannel’ must have a corresponding ‘subChannel’ within the config file then?

So sub is where the data is coming from and pub is where the data is going to?

Jeelib>

    pubchannels = ToEmonCMS,
    subchannels = ToRFM12,

HTTP>

    pubchannels = ToRFM12,
    subchannels = ToEmonCMS,

Why then does the HTTP interfacer have the serial as a pub channel (if it is going out on HTTP) - I think this is the bit that is getting me…

Good point, it looks like I left that in by error. The idea was to allow a route from emoncms back down to emonhub and say out to the RFM12/69 Pi. Perhaps as a reply to the HTTP post, but this was never implemented as part of the HTTP interfacer. So the ‘pubchannels’ setting for the HTTP interfacer is essentially not connected to anything.

The PacketGen interfacer does do this, periodically polling the packetgen HTTP api for data to be passed through emonhub and out to the rfm12/69pi board.

I’ve tested removing the pubchannels = ToRFM12 on the EmonHubMqttInterfacer here and it works fine.

Do you mean it does pass the data back to the serial interface? Could you simply remove the pubchannel statement?

For the MQTT, is there a route back from there to the serial interface? I note in the default it still refers to the ‘nodes’ Module which I think has been depreciated?

Can you subscribe to more than one sub & pub channel (is there a case when you might want to)?

Thanks for the explanation - every day a learning day :smile:.

John also queried the trailing comma - is that required?

Might be good to add something into the documentation to explain this more fully.

@borpin
The trailing comma is required.
By just adding it, my system went from not working to working.
Could well have been the result of a careless copy & paste on my part.
This thread has been informative - thx

Thanks @borpin @johnbanks

no , the http interfaces does not implement this route

Yes I think so.

Yes, but I havent used it for a long time so need to refresh on this one, its implemented in code here emonhub/src/interfacers/EmonHubMqttInterfacer.py at emon-pi · openenergymonitor/emonhub · GitHub

Yes

Yes, I think so, the comma tells the conf file decoder that the line is an array, allowing for multiple pub and sub channels. It is possible to implement it in such a way that works both ways. Perhaps one for the development list.

Yes good idea regarding documentation.

1 Like