Anonymous MQTT with Docker installation

I have installed the latest version of emoncms into a new docker. I want
it to connect to my existing MQTT service, but all the MQTT devices are configured to not use any user or password.

I cannot get the docker service to connect to connect to the MQTT service. My configuration in the web docker is as below.

MQTT_HOST - 192.168.0.4
MQTT_BASETOPIC - emon/emonesp
MQTT_USER - admin
MQTT_PASSWORD - password

I have not configured either the DB or REDIS containers. Do these need the correct MQTT config?

If I remove the MQTT_USER & MQTT_PASSWORD the webservice will not allow me to log in. Does EMON support anonymous MQTT?

How can I configure emoncms to receive data from an external MQTT service?

Thanks, George

I have been continuing to try to get this work. I have made a bit of progress, but still not there yet.

issue 1:
the docker or my ubuntu server was missing some of the mosquitto components. These have now been installed and I can now see in a command line the messages. When I use this line inside the docker I get a response.

mosquitto_sub -d -v -h 192.168.0.4 -t ‘emon/emonesp/#’

issue 2:
You cannot set an anonymous userid/password via the container environment variables. I have eddited teh settings.ini file, and now I can start up the emoncms.

issue 3:
I tried to get my emontx3 to connect to the emon container via the http API. I then redirected it back to the emoncms.org service.

As I had left this device in the inout tab it would popup an error message. I think I need to remove the emontx3 device, then it should be able to pick up the same device via MQTT.

Having said that… it still does not work.

I have got my emontx3 setup as below. It sends messages like this. How should I configure the MQTT service and bas-topic?

[mqtt]
enabled = true
host = 192.168.0.4
user = 
password = 
basetopic = emon/emonesp/#

Subscribed (mid: 1): 0
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/MSG', ... (6 bytes))
emon/emonesp/MSG 354426
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/Vrms', ... (6 bytes))
emon/emonesp/Vrms 252.94
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/P1', ... (2 bytes))
emon/emonesp/P1 18
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/P2', ... (3 bytes))
emon/emonesp/P2 695
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/P3', ... (4 bytes))
emon/emonesp/P3 1743
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/P4', ... (3 bytes))
emon/emonesp/P4 997
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/E1', ... (5 bytes))
emon/emonesp/E1 77299
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/E2', ... (6 bytes))
emon/emonesp/E2 986033
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/E3', ... (7 bytes))
emon/emonesp/E3 2364868
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/E4', ... (7 bytes))
emon/emonesp/E4 1252132
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/pulse', ... (7 bytes))
emon/emonesp/pulse 2295202
Client mosqsub|34-e70260db6728 received PUBLISH (d0, q0, r0, m0, 'emon/emonesp/freeram', ... (5 bytes))
emon/emonesp/freeram 22480

Can I confirm

  • You have emoncms in a container
  • You have a Mosquitto MQTT broker in a container
  • Your current devices use anonymous access
  • You have an emonTX with an EmonESP module

I think you have hit a limitation of Mosquitto in that, if a password file is specified, if a username/password is sent it has to be valid. A blank U/P pair will fail.

I’m pretty sure that the way emoncms mqtt servce works is that a U/P is always sent - there is no option to use anonymous access.

It would be possible at this point to check and see if a U?P was set and if not then to use anonymous access.