Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JK BMS incomplete MQTT data in Home Assistant #482

Closed
NevelSavage opened this issue Oct 6, 2023 · 8 comments
Closed

JK BMS incomplete MQTT data in Home Assistant #482

NevelSavage opened this issue Oct 6, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@NevelSavage
Copy link

What happened?

JK BMS only shows 'SoC' and 'Manufacturer' in Home Assistant.
All other items are 'unbekannt'.

public

In the OpenDTU-OnBattery web interface, other values are displayed correctly, e.g. temperature, current, etc.

MQTT Explorer shows slightly more entities (although not all of the possible ones that were published in Home Assistant), but these are rarely updated, it seems to me. The entities SoC and Manufacturer are updated cyclically. Could it possibly have something to do with that?

To Reproduce Bug

Removing the device MQTT Battery in Home Assistant.
Reboot Home Assistant and OpenDTU-OnBattery.
After the restart, the battery is recognized again, but the values are still not fully displayed.

Expected Behavior

All available entities could be displayed in Home Assistant. The cell voltages would also be interesting.

Install Method

Self-Compiled

What git-hash/version of OpenDTU?

f0a55ea

Relevant log/trace output

No response

Anything else?

No response

@NevelSavage NevelSavage added the bug Something isn't working label Oct 6, 2023
@schlimmchen
Copy link
Member

Yes, I am aware. The reason is this: The HomeAssistent integration in OpenDTU-OnBattery still only knows about the Pylontech Battery and publishes all the sensors the Pylontech would feed with data. I started working on fixing this, but have not found the time to finish it...

Thanks for using the JK BMS interface and giving feedback 😊

@NevelSavage
Copy link
Author

This is good news, it means it will work in the future.
No stress! I appreciate your work and can only thank you for it.
If I knew how I could support you in your work, I would do it. Unfortunately, my Git experience was a while ago.

@NevelSavage
Copy link
Author

NevelSavage commented Oct 28, 2023

I have added a case to the file “MqttHandlePylontechHass.cpp”. Now, depending on the BMS selected (Pylontech or JK BMS) in the config, the correct data will be published to Home Assistant. I have tested it successfully and would like to make it available to the general public. What I don't really like is that I implemented it in the file for "Pylontech" due to inexperience. Maybe someone can rename the file to "MqttHandleBMSHass.cpp"

https://github.com/NevelSavage/OpenDTU-OnBattery/blob/development/src/MqttHandlePylontechHass.cpp

// distinction PYONTCH / JK BMS / 
    switch (config.Battery_Provider) {
        case 0: // Pylontech
            publishSensor("Battery voltage", NULL, "voltage", "voltage", "measurement", "V");
            publishSensor("Battery current", NULL, "current", "current", "measurement", "A");
            publishSensor("Temperature", NULL, "temperature", "temperature", "measurement", "°C");
            publishSensor("State of Charge (SOC)", NULL, "stateOfCharge", "battery", "measurement", "%");
            publishSensor("State of Health (SOH)", "mdi:heart-plus", "stateOfHealth", NULL, "measurement", "%");
            publishSensor("Charge voltage (BMS)", NULL, "settings/chargeVoltage", "voltage", "measurement", "V");
            publishSensor("Charge current limit", NULL, "settings/chargeCurrentLimitation", "current", "measurement", "A");
            publishSensor("Discharge current limit", NULL, "settings/dischargeCurrentLimitation", "current", "measurement", "A");
        
            publishBinarySensor("Alarm Discharge current", "mdi:alert", "alarm/overCurrentDischarge", "1", "0");
            publishBinarySensor("Warning Discharge current", "mdi:alert-outline", "warning/highCurrentDischarge", "1", "0");
        
            publishBinarySensor("Alarm Temperature low", "mdi:thermometer-low", "alarm/underTemperature", "1", "0");
            publishBinarySensor("Warning Temperature low", "mdi:thermometer-low", "warning/lowTemperature", "1", "0");
        
            publishBinarySensor("Alarm Temperature high", "mdi:thermometer-high", "alarm/overTemperature", "1", "0");
            publishBinarySensor("Warning Temperature high", "mdi:thermometer-high", "warning/highTemperature", "1", "0");
        
            publishBinarySensor("Alarm Voltage low", "mdi:alert", "alarm/underVoltage", "1", "0");
            publishBinarySensor("Warning Voltage low", "mdi:alert-outline", "warning/lowVoltage", "1", "0");
        
            publishBinarySensor("Alarm Voltage high", "mdi:alert", "alarm/overVoltage", "1", "0");
            publishBinarySensor("Warning Voltage high", "mdi:alert-outline", "warning/highVoltage", "1", "0");
        
            publishBinarySensor("Alarm BMS internal", "mdi:alert", "alarm/bmsInternal", "1", "0");
            publishBinarySensor("Warning BMS internal", "mdi:alert-outline", "warning/bmsInternal", "1", "0");
        
            publishBinarySensor("Alarm High charge current", "mdi:alert", "alarm/overCurrentCharge", "1", "0");
            publishBinarySensor("Warning High charge current", "mdi:alert-outline", "warning/highCurrentCharge", "1", "0");
        
            publishBinarySensor("Charge enabled", "mdi:battery-arrow-up", "charging/chargeEnabled", "1", "0");
            publishBinarySensor("Discharge enabled", "mdi:battery-arrow-down", "charging/dischargeEnabled", "1", "0");
            publishBinarySensor("Charge immediately", "mdi:alert", "charging/chargeImmediately", "1", "0");
            break;
        case 1: // JK BMS
            // numeric sensors
            publishSensor("Battery voltage", NULL, "BatteryVoltageMilliVolt", "voltage", "measurement", "mV");
            publishSensor("Battery current", NULL, "BatteryCurrentMilliAmps", "current", "measurement", "mA");
            publishSensor("BMS temperature", NULL, "BmsTempCelsius", "temperature", "measurement", "°C");
            publishSensor("Battery temperature 1", NULL, "BatteryTempOneCelsius", "temperature", "measurement", "°C");
            publishSensor("Battery temperature 2", NULL, "BatteryTempTwoCelsius", "temperature", "measurement", "°C");
            publishSensor("State of Charge (SOC)", NULL, "stateOfCharge", "battery", "measurement", "%");
    
            // binary sensors
            publishBinarySensor("Charge enabled", "mdi:battery-arrow-up", "BatteryChargeEnabled", "yes", "no");
            publishBinarySensor("Discharge enabled", "mdi:battery-arrow-down", "BatteryDischargeEnabled", "yes", "no");
            publishBinarySensor("Balancing enabled", "mdi:battery-sync", "BalancingEnabled", "yes", "no");
    
            // common sensors        
            publishSensor("Battery Cycles", "mdi:counter", "BatteryCycles");
            publishSensor("Battery Cycle Capacity", "mdi:counter", "BatteryCycleCapacity");
            publishSensor("Status", "mdi:list-status", "StatusBitmask");
            publishSensor("Alarm", "mdi:bell", "AlarmsBitmask");
        break;
    }

@ButterBetzi
Copy link

is this issue still being worked on/is there a solution?

@NevelSavage
Copy link
Author

I have developed a working solution, which I forked in the link above. Unfortunately I don't know how to transfer this to the main fork. If you are interested, you are welcome to use my fork, which I always keep up to date.

@schlimmchen
Copy link
Member

@ButterBetzi @NevelSavage Please have a look at #640. You can find respective artifacts to test at the bottom of https://github.com/helgeerbe/OpenDTU-OnBattery/actions/runs/7790264715?pr=640 (this would be helgeerbe/development plus the Home Assistent integration I comleted). Your feedback is welcome (put it in #640).

@ButterBetzi
Copy link

ButterBetzi commented Feb 5, 2024

@schlimmchen flashed it and it works! Thank you! :)

Copy link

github-actions bot commented Apr 4, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants