Ashipa
(AshipaEko)
1 October 2023 21:50
1
Hello,
I have Solar Assistant running on my network and i can subscribe to its broker.
when i run mosquitto_sub -h 192.168.196.157 -p 1883 -v -t '#'
i get a stream of output data
I would like to have that MQTT data show up in emoncms running locally.
Please where do i enter the Solar Assistant broker details and what do i need to do to have them show up as input in emoncms?
tried editing the settings.ini as read in some other posts but nothing shows up
can’t find a place to input broker detains in INPUT/AddDevices
Thank you
borpin
(Brian Orpin)
4 October 2023 06:22
4
For data to appear in emoncms , the broker emoncms is connected to must be receiving the data. emoncms cannot connect to 2 brokers simultaneously.
The data sent to the broker emoncms is connected to, must be sent on the base topic emon/
You need to extract the data from your Solar Assistant MQTT Broker, reformat for emoncms and then send to the emoncms Broker.
I do this sort of thing in Node-RED. If the data is in HomeAssistant, you could just send it from there.
Ashipa
(AshipaEko)
4 October 2023 08:21
5
On my computer running Ubuntu
I have installed emoncms using the instructions/script
I have solar assistant running.
its broker is publishing, and i can subscribe to it as in the following example:
$ mosquitto_sub -v -h 192.168.196.157 -p 1883 -t 'solar_assistant/inverter_1/#'
solar_assistant/inverter_1/grid_frequency/state 0.0
solar_assistant/inverter_1/pv_current_1/state 0.0
solar_assistant/inverter_1/pv_power/state 662
solar_assistant/inverter_1/battery_voltage/state 25.6
solar_assistant/inverter_1/load_apparent_power/state 235
solar_assistant/inverter_1/pv_current_2/state 4.8
solar_assistant/inverter_1/temperature/state 33.0
solar_assistant/inverter_1/load_percentage/state 6
solar_assistant/inverter_1/battery_current/state 26.0
solar_assistant/inverter_1/grid_power/state 0
solar_assistant/inverter_1/pv_voltage_1/state 4.8
solar_assistant/inverter_1/pv_voltage_2/state 138.0
solar_assistant/inverter_1/pv_power_1/state 0
solar_assistant/inverter_1/device_mode/state Solar/Battery
solar_assistant/inverter_1/grid_voltage/state 2.0
solar_assistant/inverter_1/ac_output_frequency/state 49.9
solar_assistant/inverter_1/ac_output_voltage/state 229.0
solar_assistant/inverter_1/load_power/state 235
solar_assistant/inverter_1/pv_power_2/state 662
After reading up, i setup a MQTT bridge in /etc/mosquitto/conf.d/ as follows:
#Begin MQTT Bridge
connection bridge01
address 192.168.196.157:1883
#remote_username
#remote_password
topic # out 0
topic # in 0
the Solar Assistant broker does not have user/password for now.
my emoncms settings.ini file has the following entry:
[mqtt]
enabled = true
user = 'emonpi'
password = 'emonpimqtt2016'
what have i done wrong?
what do i need to do?
where do i edit the broker emoncms is connected to?
borpin
(Brian Orpin)
4 October 2023 08:28
6
Are both on the same machine?
Ashipa:
192.168.196.157
Is this the IP of the server running both Solar Assistant and Emoncms?
Ashipa:
what have i done wrong?
You didn’t read this
emoncms will only read data on the emon
base topic.
Ashipa
(AshipaEko)
4 October 2023 08:35
7
Solar Assistant is on a Pi,
emoncms is on the Ubuntu PC
the Pi and PC are linked by tailscale, so i can access the Pi directly as though they are on the same PC
I can access it freely and subscribe and publish to it.
yes.
borpin
(Brian Orpin)
4 October 2023 08:48
8
Ashipa:
yes.
Clearly it isn’t the IP of both as they are on separate machines.
Let us assume the IP of SA is .157
So this has been done on the emoncms server - correct?
If so, it is pulling the data from the SA Broker to the emoncms Broker.
so run this command but with the emoncms IP address
and you should see the same topic present as on the SA server.
Just bridging the Brokers will not solve anything as the Solar Assistant Broker is publishing the data on the base topic of solar_assistant
.
I think that as part of the bridge instruction you can change the topic in
setting so it will modify the incoming topics to emon/solar_assistant
You will need to read up on that yourself.
You only need to be either pulling the SA stuff, you don’t need to be pushing the emoncms data to the SA Broker so the topic # out
instruction is not needed.
[edit]
I think
topic # in 0 "" emon/
will do it
Ashipa
(AshipaEko)
4 October 2023 08:55
9
when i try this with the emoncms tailscale IP, i get a connection refused.
so it would appear that the bridge isn’t working?
borpin
(Brian Orpin)
4 October 2023 08:56
10
You need a user and password to the Broker on emoncms. Check the docs for it.
https://docs.openenergymonitor.org/emoncms/mqtt.html#mqtt
Ashipa
(AshipaEko)
4 October 2023 09:05
11
> Oct 04 09:02:41 fountain mosquitto[63762]: 1696410161: Loading config file /etc/mosquitto/conf.d/solar-assistant.conf
> Oct 04 09:02:41 fountain mosquitto[63762]: 1696410161: Error: Invalid bridge topic direction '0'.
> Oct 04 09:02:41 fountain mosquitto[63762]: 1696410161: Error found at /etc/mosquitto/conf.d/solar-assistant.conf:6.
> Oct 04 09:02:41 fountain mosquitto[63762]: 1696410161: Error found at /etc/mosquitto/mosquitto.conf:11.
it seems my bridge is still wrong. mosquitto.service would not start
borpin
(Brian Orpin)
4 October 2023 09:07
12
Did you read through the link to specifying a Bridge config?
borpin:
topic # in 0 “” emon/
I’d missed the #, but I did say I Think - it wasn’t tested
Ashipa
(AshipaEko)
4 October 2023 09:13
13
yeah, made that correction and it now starts.
i’m looking through that MQTT page and and it would appear i have mucked something else up
1696410647: mosquitto version 2.0.18 starting
1696410647: Using default config.
1696410647: Starting in local only mode. Connections will only be possible from clients running on this machine.
1696410647: Create a configuration file which defines a listener to allow remote access.
1696410647: For more details see https://mosquitto.org/documentation/authentication-methods/
1696410647: Opening ipv4 listen socket on port 1883.
1696410647: Error: Address already in use
1696410647: Opening ipv6 listen socket on port 1883.
1696410647: Error: Address already in use
$ ps -ef | grep mosquitto
mosquit+ 64077 1 0 09:08 ? 00:00:00 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
ubuntu 64392 60938 0 09:13 pts/0 00:00:00 grep --color=auto mosquitto
which one is the emoncms one?
borpin
(Brian Orpin)
4 October 2023 09:21
14
A recent change to Mosquitto means that by default the bBroker only listens on Localhost (security).
the sledgehammer is to specify
listener 1883 0.0.0.0
in the config file.
Better security is to bind to specific IPs
Ashipa
(AshipaEko)
4 October 2023 09:34
15
still getting a not authorised error
connection bridge01
address 192.168.196.157:1883
remote_username emonpi
remote_password emonpimqtt2016
topic # in 0 "" emon/
$ mosquitto_sub -v -h 192.168.196.184 -p 1883 -t ‘solar_assistant/inverter_1/#’
Connection error: Connection Refused: not authorised.
borpin
(Brian Orpin)
4 October 2023 09:36
16
You still do not have a Username and Password
[edit]
And if the redirect of topic is correct, you should see no topics starting solar_assistant
Ashipa
(AshipaEko)
4 October 2023 09:42
17
i should set
user emonpi
password emonpimqtt2016
in Solar Assistant?
i tried that and its the same error
borpin
(Brian Orpin)
4 October 2023 10:17
18
No, on the command line you need a password an username as per the docs
Ashipa
(AshipaEko)
4 October 2023 10:22
19
$ mosquitto_sub -v -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘test’
Connection error: Connection Refused: not authorised.
borpin
(Brian Orpin)
4 October 2023 10:23
20
well obviously as you have not specified the target machine.
[edit]
you need to add the -u
and -P
to your original command (and remove the topic spec).