Hi - I have a fresh install of EmonCMS on a Rpi B. I have MQTT working to the emoncms broker inside the RPi but I would like to direct the messages to my MQTT broker on my HomeAssistant instance on another Pi.
I am successfully connecting to both mqtt brokers using the mqtt exploer app so I know both brokers are working fine.
I seem to have read and re-read all the docs/online but must be missing something as I can’t seem to get the mqtt messages to go to my existing broker. I’ve tried:
- Editing the emonhub config and pointing to my existing broker by IP etc
- Editing the example-settings.php file to my my existing broker by IP etc (rebooting)
in both cases the mqtt messages still go to the emocms broker. I see the documents refer to a settings.php file in the /var/www/emoncms directory but the closest I have are:
[email protected]:~ $ ls -la /var/www/emoncms/scripts/services/emoncms_mqtt/ total 32
drwxr-xr-x 2 pi pi 4096 Jan 12 21:55 .
drwxr-xr-x 5 pi pi 4096 Jul 21 2021 ..
-rw-r--r-- 1 pi pi 16727 Jan 12 21:55 emoncms_mqtt.php
-rw-r--r-- 1 pi pi 2266 Jul 21 2021 emoncms_mqtt.service
I have also read in another post that you can also ‘bridge’, I’d be happy doing that also but need to know where to put the configuration for the mqtt bridge. The youtube video by Steve Cope refers to a specific mqtt.conf file but cant find that file either.
ok -so to answer my own question, (in the hope it helps others out there).
The correct file to update is settings.ini located in /var/www/emoncms
I did find other posts indicating that the settings.ini file is the one to update. I now understand the settings.php files are deprecated?
I added/modified the following lines
enabled = true
host = '192.168.1.10'
port = 1883
user = 'mymqttuser'
password = 'mymqttpassword'
basetopic = 'emon'
client_id = 'emoncms'
…now to get on with other work
Yes, there needs to be a ‘Settings’ section in the docs.
I know you’ve solved this now, but as you mentioned bridging, I thought I would respond.
I chose to leave emonhub running its own broker and bridged it to the broker on my home assistant server. To do this, you need to edit the config for Home Assistant’s Mosquito Broker.
- enable customization in the config
- use SMB or ssh to access the host folder
- Create the file
bridge.conf with the contents:
address <ip address>
topic # out 0
topic # in 0
remote_username and password are only needed if the emonhub broker requires it.
With this setup, when the HA broker starts it will connect automatically to the emonhub broker and exchange all messages.
Thanks for your input Gareth - I might give this a go this weekend. As things have stabilized I’ll make backup’s before experimenting!
Just as an side, I use WinSCP to get access to files on RPi’s on my network. Very useful tool.