substitutions: name: jbd-bms-ble device_description: "Monitor and control a Xiaoxiang Battery Management System (JBD-BMS) via BLE" external_components_source: github://syssi/esphome-jbd-bms@main esphome: name: ${name} friendly_name: ${name} comment: ${device_description} project: name: "syssi.esphome-jbd-bms" version: 2.5.0 esp32: board: wemos_d1_mini32 framework: type: esp-idf external_components: - source: ${external_components_source} refresh: 0s wifi: ssid: !secret wifi_ssid password: !secret wifi_password min_auth_mode: WPA2 reboot_timeout: 0s ota: platform: esphome logger: level: DEBUG # If you use Home Assistant please remove this `mqtt` section and uncomment the `api` component! # The native API has many advantages over MQTT: https://esphome.io/components/api.html#advantages-over-mqtt mqtt: broker: !secret mqtt_host username: !secret mqtt_username password: !secret mqtt_password id: mqtt_client reboot_timeout: 0s # api: # reboot_timeout: 0s deep_sleep: id: deep_sleep0 run_duration: 2min sleep_duration: 10min esp32_ble_tracker: ble_client: - id: client0 mac_address: !secret bms0_mac_address jbd_bms_ble: - id: bms0 ble_client_id: client0 update_interval: 2s sensor: - platform: jbd_bms_ble jbd_bms_ble_id: bms0 power: name: "power" total_voltage: name: "total voltage" state_of_charge: id: state_of_charge name: "state of charge" on_value: # Enable charging if the state of charge is below 80% - if: condition: and: - switch.is_off: charging - sensor.in_range: id: state_of_charge below: 79.0 then: - switch.turn_on: charging # Stop charging if the state of charge is above 80% - if: condition: and: - switch.is_on: charging - sensor.in_range: id: state_of_charge above: 80.0 then: - switch.turn_off: charging # Suspend deep sleep at the end of a charge cycle to stop on point (optional!) - if: condition: and: - switch.is_on: charging - sensor.in_range: id: state_of_charge above: 75.0 then: - deep_sleep.prevent: deep_sleep0 switch: - platform: ble_client ble_client_id: client0 name: "enable bluetooth connection" - platform: jbd_bms_ble jbd_bms_ble_id: bms0 charging: name: "charging" id: charging discharging: name: "discharging"