Bridge 2 MQTT Brokers and rename topics

$ mosquitto_sub -v -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emon/#’

blinking cursor. no output returned.

Connecting to the emoncms Broker which I think is on .184 IP.

mosquitto_sub -v -h -p 1883  -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#''

I have edited the above as I think you were using backticks instead of apostrophes

same. no response. just a blinking cursor

Try just asking for all topics (-t '#')

Otherwise, you need to configure mosquitto for logging and see what is happening. Logging is not enabled by default IIRC.

What is the bridge configuration now and where is this bridge config? on the emoncms server or the SA server?

Looks like logging is to stderr by default so just try

journalctl -f -u mosquitto

It might be a startup error.

The bridge conf is on the emoncms PC at /etc/mosquitto/conf.d/

content is:

#Begin MQTT Bridge
connection bridge01
remote_username emonpi
remote_password emonpimqtt2016
topic # in 0 "" emon/
$ mosquitto -v
1696420057: mosquitto version 2.0.18 starting
1696420057: Using default config.
1696420057: Starting in local only mode. Connections will only be possible from clients running on this machine.
1696420057: Create a configuration file which defines a listener to allow remote access.
1696420057: For more details see
1696420057: Opening ipv4 listen socket on port 1883.
1696420057: Error: Address already in use
1696420057: Opening ipv6 listen socket on port 1883.
1696420057: mosquitto version 2.0.18 running

Try out instead of in. Counter intuative, but reading that guide, this may be the issue.

topic # out 0 "" emon/


Actually I’m not sure this is right either :frowning: It looks like there is a relationship between these 2 commands (in and out).

You need to read the docs and see if you can work out the right combination of in and out commands.

Another bash at this - seriously trying to get my head around it. Get it working for one topic and then add wildcard :slight_smile:

I think perhaps…

Where B1 = emoncms (where bridge config is) & B2 = SA Broker

topic inverter_1/grid_frequency/state both 0 emon/SA/ solar_assistant/

Posted to B2 on topic solar_assistant/inverter_1/grid_frequency/state
Appears on B1 as emon/SA/inverter_1/grid_frequency/state

You should be able to replace grid_frequency/state with # and leave out the SA so it appears as Node Inverter_1.

i suspect i’ve been banging up the wrong alley.

went to look at the docs again, then decided to run the basic mosquitto pub and sub test.

i ran sudo systemctl stop mosquitto.service

then i tried

$ mosquitto_pub -t 'test/topic' -m 'helloWorld'
Connection error: Connection Refused: not authorised.
Error: The connection was refused.

I feel this is more of an issue with my mosquitto setup itself.

perhaps a purge, and reinstall?

Yes, i finally got one thing right.

i purged all mosquitto, and removed paho-mqtt

then installed mosquitto mosquitto-clients

bridge .conf

connection bridge01
remote_username emonpi
remote_password emonpimqtt2016
topic # both 0  emon/ solar_assistant/

now when i run:

$ mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#'
emon/inverter_1/grid_frequency/state 50.2
emon/inverter_1/pv_current_1/state 0.0
emon/inverter_1/pv_power/state 125
emon/inverter_1/battery_voltage/state 26.5
emon/inverter_1/load_apparent_power/state 164
emon/inverter_1/pv_current_2/state 0.9
emon/inverter_1/temperature/state 33.0
emon/inverter_1/load_percentage/state 4
emon/inverter_1/battery_current/state 2.0
emon/inverter_1/grid_power/state 0
emon/inverter_1/pv_voltage_1/state 0.9
emon/inverter_1/pv_voltage_2/state 139.0
emon/inverter_1/pv_power_1/state 0
emon/inverter_1/device_mode/state Solar/Battery
emon/inverter_1/grid_voltage/state 2.0
emon/inverter_1/ac_output_frequency/state 49.9
emon/inverter_1/ac_output_voltage/state 229.0
emon/inverter_1/load_power/state 164
emon/inverter_1/pv_power_2/state 125
emon/battery_1/current/state 2.0
emon/battery_1/power/state 53
emon/battery_1/state_of_charge/state 82
emon/battery_1/voltage/state 26.5
emon/total/battery_power/state 53
emon/total/battery_state_of_charge/state 82

still no sign of anything in emoncms inputs though

On which machine?

On which machine? Check the syslog for Python errors.

The emoncms machine.

a re-install solved this.

now i have the bridge working and the emoncms local broker showing the Solar Assistant data.

on the emoncms machine if i run:

$ mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#'

without even specifying the IP address, i get the output:

emon/inverter_1/grid_frequency/state 50.2
emon/inverter_1/pv_current_1/state 0.0
emon/inverter_1/pv_power/state 125
emon/inverter_1/battery_voltage/state 26.5

so i believe the bridge now works?

however, i am yet to figure out how to make that data appear in emoncms dashboard

1 Like

you said you had

This might be the issue.

If correctly installed, anything posted to the emoncms Broker on the base topic emon will just appear on the Inputs page.

In fiddling with the emoncms settings, did you change the base topic?

At this point i’m not even sure.

Which file has the proper settings for emoncms?

in settings.ini i have:

enabled = true
host = 'localhost'
port = 1883
user = 'emonpi'
password = 'emonpimqtt2016'
basetopic = 'emon'
client_id = 'emoncms'
userid = 1
multiuser = false

Ok, they are correct.

Anything in the emoncms log?

While in the settings file, check log level is 1.

In the admin page check the service is running


And check for errors in that

systemctl status emoncms_mqtt.service
$ systemctl status emoncms_mqtt.service
● emoncms_mqtt.service - Emoncms emoncms_mqtt script
     Loaded: loaded (/etc/systemd/system/emoncms_mqtt.service; enabled; vendor preset: enabled)
    Drop-In: /usr/lib/systemd/system/emoncms_mqtt.service.d
     Active: active (running) since Thu 2023-10-05 07:31:02 UTC; 14min ago
    Process: 1049 ExecStartPre=/bin/mkdir -p ${LOG_PATH} (code=exited, status=0/SUCCESS)
    Process: 1051 ExecStartPre=/bin/chown ${USER} ${LOG_PATH} (code=exited, status=0/SUCCESS)
    Process: 1054 ExecStartPre=/bin/touch ${LOG_PATH}/emoncms.log (code=exited, status=0/SUCCESS)
    Process: 1060 ExecStartPre=/bin/chmod 666 ${LOG_PATH}/emoncms.log (code=exited, status=0/SUCCESS)
   Main PID: 1061 (php)
      Tasks: 1 (limit: 6988)
     Memory: 706.6M
        CPU: 4.452s
     CGroup: /system.slice/emoncms_mqtt.service
             └─1061 /usr/bin/php /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php

Oct 05 07:31:02 fountain systemd[1]: Started Emoncms emoncms_mqtt script.

It appears i do not have an admin page :open_mouth:

How did you do the install?

Have you created 2 users?

I used the install scripts

i do not recall creating another user.

looking at it again, this user has an ID 2 number, so there must be an admin account, but i do not remember that

I think if you don’t know what the username is, you are stuck and will have to reinstall :frowning:

I tried the factory reset and i had to create a new account

Ah, yes. OK, did that leave the bridge in place?

Anything in the emoncms log?

Yes it did. The bridge still works.

The log is empty

only entry:

2023-10-05 08:46:41.348|WARN|index.php|406 Not Acceptable|dashboard/view

Did you set log level as 1?

Note make changes to settings.ini not default_settings.ini (it looks like you quoted the default settings above and these can be overridden by the settings.ini file)