Forum

Please or Register to create posts and topics.

MQTT only publishes health topic

Hi everyone,

I have an ESP-based device communicating with a JKBMS over RS485.
The RS485 communication itself works correctly — I can read and see all battery/storage data locally without any issues.

The MQTT connection is also established successfully. The device reports connected, and in MQTT Explorer I can see the following topic being published:

bms_global/health

with a payload similar to:

{
  "status": "starting",
  "health_reason": "waiting",
  ...
}

All values remain at zero.

The problem is that no other MQTT topics are being published — especially the topics containing cell voltages / battery values are missing.

So currently:

  • RS485 ↔ JKBMS communication works
  • MQTT broker connection works
  • only bms_global/health appears
  • no cell data / battery metrics topics are published

Has anyone experienced something similar or knows what could cause this behavior?

Uploaded files:
  • You need to login to have access to uploads.

Ciao grikom,

for what I can see the MQTT broker credentials are ok : dongle reports “CONNECTED”

I see you are publishing on topic “test” which I cannot find on your screenshots.
Instead on you screnshot I see a topic “BMS_GLOBAL/health” , so I think you are simply  not subscribed to the right topic.
To verify:
1-download the free sw for windows MQTTX
2-create a new connection to your broker
3-connect
4-subscribe to topic “#”  or to the topic “test” you have defined in the dongle.
If you see periodically messages coming from the dongle, all good -> you have to setup your “receiver” to subscribe to the same topic you are publishing.

If you give me more details about your broker and platform I can try to be more precise.

ScanLabs

I’m already using MQTT Explorer, and unlike some clients, it does not require manually subscribing to “#”.
It automatically shows all available topics on the broker.

On the screenshot you can already see every existing topic — there are no hidden topics and nothing else is being published besides:

bms_global/health

The broker is Mosquitto running on Home Assistant.

Also, if I manually delete the bms_global/health topic from the broker, it reappears with the exact interval configured in Publish refresh [s], so the ESP definitely publishes something correctly.

However, no battery values, cell voltages, currents, SOC, etc. are ever published.

So in my opinion the firmware/software is not working correctly rather than being a subscription issue

Hey grikom,
on the sw I’m not publishing on the topic “bms_global/health” , what you see is not coming from the dongle .
The dongle publishes only on the topic you defined on the dongle’s MQTT page.
Unless os special new cases not seen during the last 3y+ , I can garantee that the dongle in fully compatible with Mosquitto .
I encourage you to test with external subscriber, as said I’m habit to use mqttX for windows.
To avoid filtering any published topic, subscribe to “#” – soon you will see the topic “test”  ( as you defined on the dongle page )  and the json payload as shown on the dongle webpage.
If you want we can have an Anydesk session – link with me via Discord 

ScanLabs

 

Hi ScanLabs,

I disabled the TLS option and the topic immediately appeared correctly.

Thanks a lot for your help, I really appreciate it.

Best regards
grikom

Uploaded files:
  • You need to login to have access to uploads.

Cool …. but not as much … you have found a bug.
Indeed the webpage should not say “CONNECTED”  if you set TLS while it was not ….
I will investigate and fix on next 3.6.0 where I’m going to add the support for CAN BUS communciation for JK.
Thanks for indirectly reporting the bug.

ScanLabs

Thanks for looking into it 👍

While you’re working on 3.6.0, could you also consider adding native support for MQTT Discovery (Home Assistant)?

Right now I’m generating all the discovery topics manually (sensor configs, device metadata, etc.), and it’s quite a lot of repetitive work. Having built-in MQTT Discovery support would save a lot of time for many users and make integration with Home Assistant much easier and more reliable.

Even a basic implementation (auto-publishing discovery topics for common values) would already be a huge improvement.

Thanks again for your work on the CAN BUS support for JK — that’s also a really valuable addition.

And here is an example of a Growatt configuration:

// Home Assistant MQTT Discovery functions for Growatt Solar Inverter
// This file contains all MQTT discovery configuration messages
#ifndef MQTT_DISCOVERY_H
#define MQTT_DISCOVERY_H
void publishHADiscovery(PubSubClient &mqtt, const char* baseClientID, const char* uniqueClientID, const char* topicRoot, const char* buildversion) {
  char discTopic[128];
  char payload[768];
  // Solar power
  sprintf(discTopic, “homeassistant/sensor/%s_solarpower/config”, uniqueClientID);
  sprintf(payload, “{\”name\”:\”%s Solar Power\”,\”state_topic\”:\”%s/data\”,\”availability_topic\”:\”%s/connection\”,\”unique_id\”:\”%s_solarpower\”,\”unit_of_measurement\”:\”W\”,\”device_class\”:\”power\”,\”state_class\”:\”measurement\”,\”value_template\”:\”{{ value_json.solarpower }}\”,\”device\”:{\”identifiers\”:[\”%s\”],\”name\”:\”%s\”,\”model\”:\”Growatt Inverter\”,\”sw_version\”:\”%s\”}}”, baseClientID, topicRoot, topicRoot, uniqueClientID, uniqueClientID, baseClientID, buildversion);
  mqtt.publish(discTopic, payload, true);
  delay(50);
  // Output power
  sprintf(discTopic, “homeassistant/sensor/%s_outputpower/config”, uniqueClientID);
  sprintf(payload, “{\”name\”:\”%s Output Power\”,\”state_topic\”:\”%s/data\”,\”availability_topic\”:\”%s/connection\”,\”unique_id\”:\”%s_outputpower\”,\”unit_of_measurement\”:\”W\”,\”device_class\”:\”power\”,\”state_class\”:\”measurement\”,\”value_template\”:\”{{ value_json.outputpower }}\”,\”device\”:{\”identifiers\”:[\”%s\”],\”name\”:\”%s\”,\”model\”:\”Growatt Inverter\”,\”sw_version\”:\”%s\”}}”, baseClientID, topicRoot, topicRoot, uniqueClientID, uniqueClientID, baseClientID, buildversion);
  mqtt.publish(discTopic, payload, true);
  delay(50);
  // Grid voltage
  sprintf(discTopic, “homeassistant/sensor/%s_gridvoltage/config”, uniqueClientID);
  sprintf(payload, “{\”name\”:\”%s Grid Voltage\”,\”state_topic\”:\”%s/data\”,\”availability_topic\”:\”%s/connection\”,\”unique_id\”:\”%s_gridvoltage\”,\”unit_of_measurement\”:\”V\”,\”device_class\”:\”voltage\”,\”state_class\”:\”measurement\”,\”value_template\”:\”{{ value_json.gridvoltage }}\”,\”device\”:{\”identifiers\”:[\”%s\”],\”name\”:\”%s\”,\”model\”:\”Growatt Inverter\”,\”sw_version\”:\”%s\”}}”, baseClientID, topicRoot, topicRoot, uniqueClientID, uniqueClientID, baseClientID, buildversion);
  mqtt.publish(discTopic, payload, true);
  delay(50);

Uploaded files:

  • You need to login to have access to uploads.
ScanLabs has reacted to this post.
ScanLabs

Ciao grikom, let me study it . I was already implementing the feature in a different way , more complex indeed . I will check asap and give you a feedback . Good hints btw 

Hello !
HA MQTT Discovery implemented and working – want to test it ?