From cafc63427ba9450f9e46329d2cee18473964582b Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Thu, 11 Jan 2024 08:55:38 +0100 Subject: [PATCH] Add new range of JK BMS (JK-PB) support See #390 --- .github/workflows/ci.yaml | 7 ++++ esp32-jk-pb-modbus-example.yaml | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 esp32-jk-pb-modbus-example.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 805e2d92..732a8ffa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -224,6 +224,9 @@ jobs: esphome -s external_components_source components config esp32-ble-v11-old-style-example.yaml esphome -s external_components_source components config esp32-ble-v11-old-style-example-debug.yaml esphome -s external_components_source components config esp32-ble-v11-old-style-example-faker.yaml + - name: Compile esp32 (modbus) example configurations + run: | + esphome config esp32-jk-pb-modbus-example.yaml - name: Write yaml-snippets/secrets.yaml shell: bash @@ -288,3 +291,7 @@ jobs: run: | esphome -s external_components_source components compile esp32-ble-example-faker.yaml esphome -s external_components_source components compile esp32-ble-v11-example-faker.yaml + esphome -s external_components_source components compile esp32-ble-v11-example.yaml + - name: Compile esp32 (modbus) example configurations + run: | + esphome compile esp32-jk-pb-modbus-example.yaml diff --git a/esp32-jk-pb-modbus-example.yaml b/esp32-jk-pb-modbus-example.yaml new file mode 100644 index 00000000..f636aee4 --- /dev/null +++ b/esp32-jk-pb-modbus-example.yaml @@ -0,0 +1,71 @@ +substitutions: + name: jk-bms + device_description: "Monitor a JK-BMS (JK-PB series) via Modbus" + external_components_source: github://syssi/esphome-jk-bms@main + tx_pin: GPIO16 + rx_pin: GPIO17 + +esphome: + name: ${name} + comment: ${device_description} + project: + name: "syssi.esphome-jk-bms" + version: 1.5.0 + +esp32: + board: wemos_d1_mini32 + framework: + type: esp-idf + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + +ota: + +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 + +# api: + +uart: + - id: uart_0 + baud_rate: 115200 + rx_buffer_size: 384 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + +modbus: + id: modbus0 + +modbus_controller: + - id: bms0 + # Address of the Modbus slave device on the bus + address: 0x01 + modbus_id: modbus0 + setup_priority: -10 + update_interval: 5s + command_throttle: 50ms + +sensor: + # 0x1200 index 0x90 Battery Voltage + - platform: modbus_controller + modbus_controller_id: bms0 + name: "${name} total voltage" + address: 0x1290 + register_type: holding + value_type: U_DWORD_R + unit_of_measurement: "V" + device_class: voltage + state_class: measurement + accuracy_decimals: 3 + filters: + - multiply: 0.001