Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A containerized version of NodeJBD / bms-tools for easy monitoring of your JBD BMS with MQTT on Docker.

License

NotificationsYou must be signed in to change notification settings

robwolff3/jbd2mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation


What is this?

A containerized version of NodeJBD / bms-tools for easy monitoring of your JBD BMS with MQTT on Docker. My use case is for integration with Home Assistant but with MQTT your imagination is the limit. Currently only supports a serial UART connection (tested via USB) and only capable ofread only access of the BMS.

mickwheelz andMrSurly did all the work and build the underlying tools. If you like this project go check out and star their repositories below:


Connecting to your BMS

Compatibility

In theory this container should work with any JBD BMS however these are the confirmed working models by mickwheelz and I:

BMS ModelInterfaceNotesStatus
JBD SP04S028AUART150A 4s LiFePO4 BMS
JBD SP04S28A4SUART100A 4s LiFePO4 BMS

Connection

This project currently only supports a serial UART connection to the BMS. It has only been tested tested through a USB to UART serial adapter.

USB UART Serial Connection

The JBD BMS has a 5v TTL serial connection UART port for communication. Connect TX, RX and GND and you should be good to go. I used a CP2102 based USB adapter from amazon and made a custom cable. I think ready made adapters exist over at Overkill Solar, Current Connected or AliExpress.

Important Connection Notes:
  • The UART port has 4 pins, GND, TX, RX and VCC. I have seen reports of VCC putting out ~10v so I wouldNOT connect anything to VCC. It is not needed for the CP2102 based USB adapter or any other adapter.
  • Seeing how there is only one UART port on the BMS I don't think the USB adapter and bluetooth adapter can be used at the same time.

Running the Container

Docker Run

Here is the command to run the container using the Docker run command:

$ docker run -d --name=jbd2mqtt \    --restart unless-stopped \    -e NODEJBD_SERIALPORT=/dev/ttyUSB0 \    -e NODEJBD_MQTTBROKER=mosquitto \    -e NODEJBD_MQTTUSER=username \    -e NODEJBD_MQTTPASS=password \    --device /dev/ttyUSB0 \    robwolff3/jbd2mqtt

Docker Compose

And here is an example of running the container using docker compose:

version:'3'services:jbd2mqtt:container_name:jbd2mqttimage:robwolff3/jbd2mqttrestart:unless-stoppedenvironment:NODEJBD_SERIALPORT:/dev/ttyUSB0NODEJBD_MQTTBROKER:mosquittoNODEJBD_MQTTUSER:usernameNODEJBD_MQTTPASS:passworddevices:      -/dev/ttyUSB0

Environment Variables

Lastly all the environment variables you can define. Same as the NodeJBD project.

Env VarDescriptionExample
NODEJBD_SERIALPORTREQUIRED: Serial port your BMS is connected to/dev/ttyUSB0
NODEJBD_BAUDRATEThe baud rate to use for serial communications, defaults to 960014400
NODEJBD_MQTTBROKERThe address of your MQTT Broker192.168.0.10
NODEJBD_MQTTUSERThe username for your MQTT BrokermqttUser
NODEJBD_MQTTPASSThe password for your MQTT BrokermqttPass
NODEJBD_MQTTTOPICMQTT topic to publish to defaults to 'NodeJBD'MyTopic
NODEJBD_POLLINGINTERVALHow frequently to poll the controller in seconds, defaults to 1060
NODEJBD_LOGLEVELSets the logging level, useful for debuggingtrace

Defining Sensors in Home Assistant

Here are what I would consider the more primary sensors:

sensor:  -platform:mqttname:"Battery SOC"state_topic:"NodeJBD/pack"value_template:"{{ value_json['packSOC'] }}"unit_of_measurement:"%"device_class:battery  -platform:mqttname:"Battery Amp Hours"state_topic:"NodeJBD/pack"value_template:"{{ value_json['packBalCap'] }}"unit_of_measurement:"Ah"device_class:energy  -platform:mqttname:"Battery Volts"state_topic:"NodeJBD/pack"value_template:"{{ value_json['packV'] }}"unit_of_measurement:"V"device_class:voltage  -platform:mqttname:"Battery Amps"state_topic:"NodeJBD/pack"value_template:"{{ value_json['packA'] }}"unit_of_measurement:'A'device_class:currenttemplate:  -sensor:      -name:"Battery Watts"unique_id:battery_wattsstate:"{{ ( states('sensor.battery_1_volts') | float ) * ( states('sensor.battery_1_amps') | float ) }}"unit_of_measurement:'W'device_class:power

And here are some of the more verbose sensors you may or may not want.

sensor:  -platform:mqttname:"Battery Cycles"state_topic:"NodeJBD/pack"value_template:"{{ value_json['packCycles'] }}"  -platform:mqttname:"Battery Volts Cell-1"state_topic:"NodeJBD/cells"value_template:"{{ value_json['cell0V'] }}"unit_of_measurement:"V"device_class:voltage  -platform:mqttname:"Battery Volts Cell-2"state_topic:"NodeJBD/cells"value_template:"{{ value_json['cell1V'] }}"unit_of_measurement:"V"device_class:voltage  -platform:mqttname:"Battery Volts Cell-3"state_topic:"NodeJBD/cells"value_template:"{{ value_json['cell2V'] }}"unit_of_measurement:"V"device_class:voltage  -platform:mqttname:"Battery Volts Cell-4"state_topic:"NodeJBD/cells"value_template:"{{ value_json['cell3V'] }}"unit_of_measurement:"V"device_class:voltage  -platform:mqttname:"Battery Bal Cell-1"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatus'][0].cell0 }}"  -platform:mqttname:"Battery Bal Cell-2"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatus'][1].cell1 }}"  -platform:mqttname:"Battery Bal Cell-3"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatus'][2].cell2 }}"  -platform:mqttname:"Battery Bal Cell-4"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatus'][3].cell3 }}"  -platform:mqttname:"Battery Bal High Cell-1"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatusHigh'][0].cell0 }}"  -platform:mqttname:"Battery Bal High Cell-2"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatusHigh'][1].cell1 }}"  -platform:mqttname:"Battery Bal High Cell-3"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatusHigh'][2].cell2 }}"  -platform:mqttname:"Battery Bal High Cell-4"state_topic:"NodeJBD/pack"value_template:"{{ value_json['balanceStatusHigh'][3].cell3 }}"  -platform:mqttname:"Battery Cell Overvolt"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].singleCellOvervolt }}"  -platform:mqttname:"Battery Cell Undervolt"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].singleCellUndervolt }}"  -platform:mqttname:"Battery Pack Overvolt"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].packOvervolt }}"  -platform:mqttname:"Battery Pack Undervolt"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].packUndervolt }}"  -platform:mqttname:"Battery Charge Overtemp"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].chargeOvertemp }}"  -platform:mqttname:"Battery Charge Undertemp"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].chargeUndertemp }}"  -platform:mqttname:"Battery Discharge Overtemp"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].dischargeOvertemp }}"  -platform:mqttname:"Battery Discharge Undertemp"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].dischargeUndertemp }}"  -platform:mqttname:"Battery Charge Overcurrent"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].chargeOvercurrent }}"  -platform:mqttname:"Battery Discharge Overcurrent"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].dischargeOvercurrent }}"  -platform:mqttname:"Battery Short Circut"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].shortCircut }}"  -platform:mqttname:"Battery Frontend Detection IC Error"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].frontEndDetectionICError }}"  -platform:mqttname:"Battery Software Lock MOS"state_topic:"NodeJBD/pack"value_template:"{{ value_json['protectionStatus'].softwareLockMOS }}"  -platform:mqttname:"Battery FET Status Charging"state_topic:"NodeJBD/pack"value_template:"{{ value_json['FETStatus'].charging }}"  -platform:mqttname:"Battery FET Status Discharging"state_topic:"NodeJBD/pack"value_template:"{{ value_json['FETStatus'].discharging }}"  -platform:mqttname:"Battery Temp NTC0"state_topic:"NodeJBD/pack"value_template:"{{ value_json['tempSensorValues'].NTC0 }}"unit_of_measurement:"C"device_class:temperature  -platform:mqttname:"Battery Temp NTC1"state_topic:"NodeJBD/pack"value_template:"{{ value_json['tempSensorValues'].NTC1 }}"unit_of_measurement:"C"device_class:temperature  -platform:mqttname:"Battery Temp NTC2"state_topic:"NodeJBD/pack"value_template:"{{ value_json['tempSensorValues'].NTC2 }}"unit_of_measurement:"C"device_class:temperature

About

A containerized version of NodeJBD / bms-tools for easy monitoring of your JBD BMS with MQTT on Docker.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp