Struggling to receive mqtt messages from DIYv4 bms

I am not entirely new to mqtt as I have my eversol inverter connected to a raspberry pi which is using mqtt to talk to my homeassistant pi and that is working fine.

I had hoped I would be able to achieve a similarly joined up system between my esp32 and homeassistant, but alas I have struggled all day in vain so far.

I began by simply putting my home assistant mqtt broker credentials into the diybmsv4 web integration page, ticking enable check box and then cycling the power.

I then reasoned it could be potentially that i need an emonpi (which i dont have so i tried to spoof having one using docker on my laptop). I am impressed with the look of the emoncms but couldnt see away of getting the diyv4bms to talk to it from that side.

I then had a look at the Visualize data from the diyBMS · stuartpittaway/diyBMSv4 Wiki · GitHub
page specifically " i assume you have done the following"

  1. Created an user in Mosquitto
  2. Configure diyBMS to use the Mosquitto server and you are receiving data → use MQTTBox to test and subscribe to diyBMS/# and see if data is indeed coming from diyBMS, if not check your diyBMS and Mosquitto settings
  3. Setup NodeRED server and make a connection to Mosquitto server. You can test that you get data by drawing a connection between the MQTT node and a debug node.

so i installed mosquitto on my laptop and tried to get the mqtt explorer to see the broker. (it would if i assigned the mqtt explorer ip to 127.0.0.1 but not when it was its lan ip. this might be my issue or a red herring.

In short my issue is that I am yet to see any mqtt messages from the esp32 to the broker on my laptop or my home assistant instance on my pi. I also read through

and more specifically tried

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

both with those params and my own.
I even looked in the source of the diyv4bms and set the values in the integrations page to match the default values and spoofed my laptops ip address to match 192.168.0.26 to rule out something daft like the credentials not even being set.

Is it possible to attach to the esp32 serial to verify the passwords and usernames are being set?

any help here would be amazing as i’ve spent about 8 hours going around the houses on this and i think if i could only see the mqtt messages on the broker id be sorted.

Mqtt does work reliability from diybms.

First thing to try is disabling any firewall software running on the mqtt broker computer.

I will try that but my hunch says its not a firewall issue as my eversolar pi would be blocked from talking to my homeassistant pi if firewalls were causing issues.

Try this… Which should spit out all MQTT messages received on the system

mosquitto_sub -v -u emonpi -P emonpimqtt2016 -t ‘#’

Obviously, change the username and password if needed.- this would need to be on the home assistant machine - I’m assuming thats using Mosquitto for its MQTT broker.

right, i have this working locally on my laptop which is massive progress.

steps that helped.

  1. allow an incoming rule for port 1883 on your firewall.
  2. get passwords correct (you don’t need to use the encrypted password on the bms, just when settings it up in the broker)
  3. have the following in mosquitto.conf
    allow_anonymous true
    listener 1883 (your broker ip)
  4. ensure you use the -c flag for specifying your mosquitto.conf configuration file to use otherwise it just defaults to local only.

so some of this I think is breaking changes with version 2.0 of mosquitto broker. I have now the challenge of converting this knowledge into getting it working on homeassistant on the Pi since I am yet to solve that hurdle.

only after 2 days and all this stabbing about in the dark did the mosquitto_sub actually detect anything.

i now see the bms mqtt topics in MQTT explorer too.

image
thanks for all the help so far Stuart.
Also given that my confidence is restored in the mqtt sending abilities of the bms do you have 4 spare slave modules i could buy?
failing this I will have to do a bulk order of ver 4.5 and ver 4.4 slave boards and some attinys from elsewhere since jlcpcb is out of stock on both types and act as a one man fab shop to solder on the main chip and flash them. Nothing is ever as simple as it should be.

A bit more progress.

one reason home assistant wasnt loving my setup is that the mqtt broker has a change which mean that you couldnt have homeassistant as a user. unfortunately such a breaking change meant that ive had to reset the user name on my broker by adding an extra user in homeassistant with a password. (for simplicity i kept the original broker password) i then has to whizz round all my mqtt tasmotised devices and reset the user and copy and paste the same password in.

Anyway, im a little closer as now i have seen the ip address of the diybms in the log of the broken on the homeassistant on the pi however it isnt autodiscovering like my eversol monitors or tasmota devices. A similar mosquitto_sub command on terminal coressh window is not showing me any output either. my guess is that i need to do some yaml configuration somewhere but today i am pretty exhausted on it. at one point today changing the login yaml on the broken addon almost broke the pi and backups as it froze the supervisor which no real clues as to why. after a few unsuccessful soft reboots i turned it off and on again and eventually everything came back to almost normal except for my mqtt configuration which would reset so i uninstalled the broker and the integration and thats when i realised i needed to rename the user from homeassistant to something else.

anyway i am inching closer now and there have been a few backwards steps but thankfully it hasnt knackered my solar data collecting or the energy monitoring which is via a shelly em and not mqtt.