Skip to content

Commit

Permalink
Feature: add HASS autodiscovery for JBD BMS
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Oct 30, 2024
1 parent ad0e9fa commit c55ff7d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/MqttHandleBatteryHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,43 @@ void MqttHandleBatteryHassClass::loop()
publishBinarySensor("Charge enabled", "mdi:battery-arrow-up", "charging/chargeEnabled", "1", "0");
publishBinarySensor("Discharge enabled", "mdi:battery-arrow-down", "charging/dischargeEnabled", "1", "0");

break;
case 6: // JBD BMS
// caption icon topic dev. class state class unit
publishSensor("Voltage", "mdi:battery-charging", "voltage", "voltage", "measurement", "V");
publishSensor("Current", "mdi:current-dc", "current", "current", "measurement", "A");
publishSensor("Cell Min Voltage", NULL, "CellMinMilliVolt", "voltage", "measurement", "mV");
publishSensor("Cell Average Voltage", NULL, "CellAvgMilliVolt", "voltage", "measurement", "mV");
publishSensor("Cell Max Voltage", NULL, "CellMaxMilliVolt", "voltage", "measurement", "mV");
publishSensor("Cell Voltage Diff", "mdi:battery-alert", "CellDiffMilliVolt", "voltage", "measurement", "mV");
publishSensor("Battery Temperature 1", "mdi:thermometer", "BatteryTempOneCelsius", "temperature", "measurement", "°C");
publishSensor("Battery Temperature 2", "mdi:thermometer", "BatteryTempTwoCelsius", "temperature", "measurement", "°C");
publishSensor("Alarms Bitmask", NULL, "AlarmsBitmask");
publishSensor("Charge Cycles", "mdi:counter", "BatteryCycles");
publishSensor("Available Capacity", NULL, "ActualBatteryCapacityAmpHours");

publishBinarySensor("Charging enabled", "mdi:battery-arrow-up", "BatteryChargeEnabled", "yes", "no");
publishBinarySensor("Discharging enabled", "mdi:battery-arrow-down", "BatteryDischargeEnabled", "yes", "no");
publishBinarySensor("Balancing enabled", "mdi:scale-balance", "BatteryBalancingEnabled", "yes", "no");

#define PBS(a, b, c) publishBinarySensor("Alarm: " a, "mdi:" b, "alarms/" c, "1", "0")
PBS("Cell Overvoltage", "battery-alert", "CellOverVoltage");
PBS("Cell Undervoltage", "battery-alert", "CellUnderVoltage");
PBS("Pack Overvoltage", "fuse-alert", "PackOverVoltage");
PBS("Pack Undervoltage", "fuse-alert", "PackUnderVoltage");
PBS("Charging Overtemperature", "thermometer-alert", "ChargingOverTemperature");
PBS("Charging Undertemperature", "thermometer-alert", "ChargingLowTemperature");
PBS("Discharging Overtemperature", "thermometer-alert", "DischargingOverTemperature");
PBS("Discharging Undertemperature", "thermometer-alert", "DischargingLowTemperature");
PBS("Charging Overcurrent", "fuse-alert", "ChargingOverCurrent");
PBS("Discharging Overcurrent", "fuse-alert", "DischargeOverCurrent");
PBS("Short Circuit", "fuse-alert", "ShortCircuit");
PBS("IC Frontend Error", "battery-alert-variant-outline", "IcFrontEndError");
PBS("MOS Software Lock", "battery-alert-variant-outline", "MosSoftwareLock");
PBS("Reserved 1", "battery-alert-variant-outline", "Reserved1");
PBS("Reserved 2", "battery-alert-variant-outline", "Reserved2");
PBS("Reserved 3", "battery-alert-variant-outline", "Reserved3");
#undef PBS
break;
}

Expand Down

0 comments on commit c55ff7d

Please sign in to comment.