From c3a80b9f8cd35c67c6df7fc66da696a85830fadd Mon Sep 17 00:00:00 2001 From: Fahmula Date: Thu, 10 Jul 2025 18:47:47 -0400 Subject: [PATCH 1/2] feat: Add Pylontech RS485 inverter protocol This commit introduces a new output driver for YamBMS, enabling communication with inverters that use the Pylontech RS485 protocol. This provides a robust alternative to the existing CANbus interface. The implementation is architecturally identical to the proven CANbus pattern. Key changes include: * **New Core Logic Package:** [`packages/yambms/yambms_rs485.yaml`](packages/yambms/yambms_rs485.yaml) contains the interval engine, proxy sensor definitions, and links core YamBMS data to the `esphome-pylontech-rs485` external component. * **New Reusable Board Option:** [`packages/board/board_options_itf_esp32_rs485.yaml`](packages/board/board_options_itf_esp32_rs485.yaml) defines a standard 9600 baud UART interface for connecting to the inverter. * **New Example Configuration:** [`YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml`](YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml) demonstrates a complete, working setup using the new packages. --- YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml | 293 ++++++++++++++++++ .../board/board_options_itf_esp32_rs485.yaml | 25 ++ packages/yambms/yambms_rs485.yaml | 218 +++++++++++++ 3 files changed, 536 insertions(+) create mode 100644 YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml create mode 100644 packages/board/board_options_itf_esp32_rs485.yaml create mode 100644 packages/yambms/yambms_rs485.yaml diff --git a/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml b/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml new file mode 100644 index 0000000..011d5d7 --- /dev/null +++ b/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml @@ -0,0 +1,293 @@ +# Updated : 2025.07.10 +# Version : 1.5.7 +# GitHub : https://github.com/Sleeper85/esphome-yambms + +# YamBMS ( Yet another multi-BMS Merging Solution ) + +# This YAML is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +######################## YamBMS Remote Packages Version ######################## + +# You can compile this YAML directly without the `packages` folder. +# The packages will be automatically downloaded from GitHub. +# Don't forget to configure your WiFi credentials in the secrets.yaml + +################################################################################ + +# If needed, configure a static IP here +# wifi: +# manual_ip: +# static_ip: 192.168.0.85 +# gateway: 192.168.0.1 +# subnet: 255.255.255.0 +# dns1: 8.8.8.8 +# dns2: 8.8.4.4 + +logger: + level: INFO # VERBOSE / DEBUG / INFO / WARN + +ota: + platform: esphome + +# Please use the native `api` component instead of the `mqtt` section. +# If you use Home Assistant, the native API is more lightweight. +# If there is no HA server connected to this API, the ESP32 reboots every 15 minutes to try to resolve the problem. +# The "reboot_timeout: 0s" option will keep your ESP32 up and running even if you lose connection to your HA server. +api: + reboot_timeout: 0s + +# If you don't want to use ESPHome's native API you can use MQTT instead. +# In this case don't forget to remove the 'api:' section. +# mqtt: +# broker: !secret mqtt_host +# username: !secret mqtt_username +# password: !secret mqtt_password +# id: mqtt_client + +# Please note that enabling this component will take up a lot of memory and may decrease +# stability and be the cause of reboot depending on the capabilities of the board used. +# web_server: +# port: 80 +# log: false +# ota: false + +# +--------------------------------------+ +# | Global Settings | +# +--------------------------------------+ +substitutions: + # Name + friendly_name : 'YamBMS' # Prefix added in front of the `entity display name`, also used to classify them. + hostname: 'yambms' # Name of your ESPHome node registered on the IP network (DNS name, must be unique) and prefix added in front of the `entity id`. + name: '' # This name can be added as a second prefix, both for the `entity display name` and the `entity id`, you can leave it blank. + # +--------------------------------------+ + # | YamBMS Settings | + # +--------------------------------------+ + # Please read the cut-off charging logic README to understand how the YamBMS works + yambms_id: 'yambms1' + yambms_name: 'YamBMS 1' + yambms_update_interval: '1s' + # Input numbers can be displayed as a slider or an input box, options are 'slider' or 'box'. + yambms_input_number_mode: 'slider' + # Please check and fill in the options below correctly according to your battery chemistry and number of cells in series. + # These parameters are important and used for charging logic. + # Battery Chemistry + yambms_battery_chemistry: '1' # 1-LFP | 2-Li-ion | 3-LTO + # Number of cells in series + yambms_cell_count: '16' + # Bulk / Absorption Voltage : corresponds to the Bulk voltage that will be used to charge the battery. (LFP : 55.2V = 3.45V/Cell for 16S battery) + yambms_bulk_v: '55.2' + # Float Voltage : corresponds to the voltage at which the battery would be maintained at the end of charge. (LFP : 53.6V = 3.35V/Cell for 16S battery) + yambms_float_v: '53.6' + # Rebulk voltage, voltage from which a new Bulk charge can start. (LFP : 52.8V = 3.3V/Cell for 16S battery) + yambms_rebulk_v: '52.8' + # Maximum time in minutes that the cut-off step can last before charging is complete + # If your cells are properly balanced this step ends at the fastest after the `cut-off timer` + # This timer can be deactivated with a switch + yambms_eoc_timer: '30' + # Time in seconds during which the end of charge conditions must be respected (cut-off + cells not equalizing) + yambms_cutoff_timer: '60' + # +--------------------------------------+ + # | Shunt Settings | + # +--------------------------------------+ + shunt_update_interval: '3s' # frequency at which Shunt data is refreshed + shunt_combine_interval: '1s' # frequency at which Shunt data is combined in YamBMS + # +--------------------------------------+ + # | BMS Settings | + # +--------------------------------------+ + bms_update_interval: '3s' # frequency at which BMS data is refreshed, going below '3s' can cause problems + bms_combine_interval: '1s' # frequency at which BMS data is combined in YamBMS + bms_cutoff_timer: '50s' # time during which the end of charge conditions must be respected (cut-off + cells not equalizing) + +# +--------------------------------------+ +# | Packages | +# +--------------------------------------+ + +# PLEASE READ : https://github.com/Sleeper85/esphome-yambms/blob/main/documents/README/YamBMS_main_YAML_HowTo.md + +packages: + + ################ >>> CONFIG & CUSTOM LP <<< ################ + + # Local Packages intended for creating custom codes + # or sharing settings between several main.yaml + + # yambms_config: !include yambms_config.yaml + # yambms_custom: !include yambms_custom.yaml + + ############### >>> UNCOMMENT YOUR BOARD <<< ############### + ############### >>> ONLY ONE BOARD ! <<< ############### + + board: + url: https://github.com/Sleeper85/esphome-yambms + ref: main + refresh: 0s + files: + - path: 'packages/board/board_ESP32_Generic.yaml' + # - path: 'packages/board/board_ESP32_DevKit-V1.yaml' + # - path: 'packages/board/board_ESP32_Atom-Lite.yaml' + # - path: 'packages/board/board_ESP32_EVB.yaml' + # - path: 'packages/board/board_ESP32_LilyGo-T-CAN485.yaml' + # - path: 'packages/board/board_ESP32-C3_DevKitM-1.yaml' + # - path: 'packages/board/board_ESP32-C3_ETH01-EVO.yaml' + # - path: 'packages/board/board_ESP32-S3_AtomS3-Lite.yaml' + # - path: 'packages/board/board_ESP32-S3_DevKitC-1_LED-38.yaml' + # - path: 'packages/board/board_ESP32-S3_DevKitC-1_LED-48.yaml' + # - path: 'packages/board/board_ESP32-S3_LilyGo-T-Connect.yaml' + # - path: 'packages/board/board_ESP32-S3_Touch-LCD-4.3.yaml' + # - path: 'packages/board/board_ESP32-S3_Touch-LCD-7.yaml' + # - path: 'packages/board/board_ESP32-S3_XIAO.yaml' + # - path: 'packages/board/board_ESP32-S3_YBoard.yaml' + + # - path: 'packages/board/board_ESP32-S3_AtomS3.yaml' + # vars: + # display_auto_next_page_interval: '5s' + # display_rotation: '0' # 0/90/180/270 rotation angle in degrees + + # - path: 'packages/board/board_ESP32-S3_AtomS3R.yaml' + # vars: + # display_auto_next_page_interval: '5s' + # display_rotation: '0' # 0/90/180/270 rotation angle in degrees + + # LilyGo T-Connect Pro + # Importing the display also activates PSRAM. + # Also note that the display update takes about 120 ms, as indicated in the logs: + # "Component display took a long time for an operation (124 ms)." + # Board + # - path: 'packages/board/board_ESP32-S3_LilyGo-T-Connect-Pro.yaml' + # Display + # - path: 'packages/board/board_options_display_480x222.yaml' + # vars: + # display_auto_next_page_interval: '5s' + + ########### >>> UNCOMMENT YOUR BOARD OPTIONS <<< ########### + + board_options: + url: https://github.com/Sleeper85/esphome-yambms + ref: main + refresh: 0s + files: + # UART 1 + # - path: 'packages/board/board_options_itf_uart_esp_1.yaml' + # UART 2 + # - path: 'packages/board/board_options_itf_uart_esp_2.yaml' + # UART 3 + # - path: 'packages/board/board_options_itf_uart_esp_3.yaml' + + # ESP32_RS485 (M5Stack RS485 base/unit) + - path: 'packages/board/board_options_itf_esp32_rs485.yaml' + vars: + rs485_node_id: 'rs485_inverter_1' + + ############################################################ + + # You don't have to import a shunt but you must import at least one BMS. + + # UART Shunt + # shunt: + # url: https://github.com/Sleeper85/esphome-yambms + # ref: main + # refresh: 0s + # files: + # # Shunt 1 + # - path: 'packages/shunt/shunt_combine_Victron_SmartShunt_UART.yaml' # shunt_combine_Junctek_KHF_UART.yaml + # vars: + # shunt_id: '1' # must be a number + # shunt_name: 'Shunt 1' + # shunt_uart_id: 'uart_esp_1' + + # BLE Shunt + # shunt: + # url: https://github.com/Sleeper85/esphome-yambms + # ref: main + # refresh: 0s + # files: + # # Shunt 1 + # - path: 'packages/shunt/shunt_combine_Victron_SmartShunt_BLE.yaml' + # vars: + # shunt_id: '1' # must be a number + # shunt_name: 'Shunt 1' + # shunt_mac_address: '60:A4:23:91:8F:55' # Your MAC address + # shunt_encryption_key: '0df4d0395b7d1a876c0c33ecb9e70dcd' # Your encryption key + + bms: + url: https://github.com/Sleeper85/esphome-yambms + ref: main + refresh: 0s + files: + # BMS 1 + - path: 'packages/bms/bms_combine_JK_BLE_standard.yaml' + vars: + bms_id: '1' # must be a number + bms_name: 'JK-BMS 1' + bms_ble_protocol_version: 'JK02_32S' # JK02_24S < hardware version 11.0 >= JK02_32S + bms_ble_mac_address: 'C8:47:8C:10:7E:AA' + # Maximum cell charging cycles is used to calculate the battey SoH. + # MB31=8000.0, LF280K v3=8000.0, LF280K v2=6000.0, LF280=3000.0 (decimal is required) + bms_cell_max_cycles: '6000.0' + # BMS 2 + - path: 'packages/bms/bms_combine_JK_BLE_standard.yaml' + vars: + bms_id: '2' # must be a number + bms_name: 'JK-BMS 2' + bms_ble_protocol_version: 'JK02_32S' # JK02_24S < hardware version 11.0 >= JK02_32S + bms_ble_mac_address: 'C8:47:8C:EE:16:EA' + # Maximum cell charging cycles is used to calculate the battey SoH. + # MB31=8000.0, LF280K v3=8000.0, LF280K v2=6000.0, LF280=3000.0 (decimal is required) + bms_cell_max_cycles: '6000.0' + + # bms_options: + # url: https://github.com/Sleeper85/esphome-yambms + # ref: main + # refresh: 0s + # files: + # # BMS 1 + # - path: 'packages/bms/bms_options_charging_logic.yaml' + # vars: + # bms_id: '1' # must be a number + # # BMS 2 + # - path: 'packages/bms/bms_options_charging_logic.yaml' + # vars: + # bms_id: '2' # must be a number + + yambms: + url: https://github.com/Sleeper85/esphome-yambms + ref: main + refresh: 0s + files: + - path: 'packages/yambms/yambms.yaml' + + rs485: + url: https://github.com/Sleeper85/esphome-yambms + ref: main + refresh: 0s + files: + - path: 'packages/yambms/yambms_rs485.yaml' + vars: + rs485_id: 'rs485_1' + rs485_node_id: 'rs485_inverter_1' + rs485_update_timeout: '5s' + +# +--------------------------------------+ +# | DEBUG ( logger level must be DEBUG ) | +# +--------------------------------------+ + + debug: + url: https://github.com/Sleeper85/esphome-yambms + ref: main + refresh: 0s + files: + - path: packages/base/device_debug_ESP32.yaml + vars: + debug_name: 'Debug' + debug_update_interval: '5s' diff --git a/packages/board/board_options_itf_esp32_rs485.yaml b/packages/board/board_options_itf_esp32_rs485.yaml new file mode 100644 index 0000000..11a5da5 --- /dev/null +++ b/packages/board/board_options_itf_esp32_rs485.yaml @@ -0,0 +1,25 @@ +# Updated : 2025.07.10 +# Version : 1.5.7 +# GitHub : https://github.com/Sleeper85/esphome-yambms + +# YamBMS ( Yet another multi-BMS Merging Solution ) + +# This YAML is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +uart: + - id: ${rs485_node_id} + tx_pin: ${tx_pin_4} + rx_pin: ${rx_pin_4} + baud_rate: 9600 + rx_buffer_size: 256 \ No newline at end of file diff --git a/packages/yambms/yambms_rs485.yaml b/packages/yambms/yambms_rs485.yaml new file mode 100644 index 0000000..45fae77 --- /dev/null +++ b/packages/yambms/yambms_rs485.yaml @@ -0,0 +1,218 @@ +# Updated : 2025.07.10 +# Version : 1.2.0 +# GitHub : https://github.com/fahmula/esphome-pylontech-rs485 + +# YamBMS ( Yet another multi-BMS Merging Solution ) + +# This YAML is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +external_components: + - source: github://fahmula/esphome-pylontech-rs485@main + refresh: 0s + +select: + - platform: template + name: "${name} RS485 Protocol" + id: ${rs485_id}_protocol + options: + - "Pylontech" + - "Disabled" + restore_value: true + initial_option: "Pylontech" + optimistic: true + entity_category: config + +sensor: + - platform: template + id: yambms_proxy_soc + internal: true + - platform: template + id: yambms_proxy_voltage + internal: true + - platform: template + id: yambms_proxy_current + internal: true + - platform: template + id: yambms_proxy_temperature + internal: true + - platform: template + id: yambms_proxy_soh + internal: true + - platform: template + id: yambms_proxy_cycle_count + internal: true + - platform: template + id: yambms_proxy_max_cell_v + internal: true + - platform: template + id: yambms_proxy_min_cell_v + internal: true + - platform: template + id: yambms_proxy_max_temp + internal: true + - platform: template + id: yambms_proxy_min_temp + internal: true + - platform: template + id: yambms_proxy_max_charge_v + internal: true + - platform: template + id: yambms_proxy_min_discharge_v + internal: true + - platform: template + id: yambms_proxy_max_charge_i + internal: true + - platform: template + id: yambms_proxy_max_discharge_i + internal: true + +binary_sensor: + # --- Passive Proxy Alarm/Protection Sensors --- + - platform: template + id: yambms_proxy_total_voltage_high_alarm + internal: true + - platform: template + id: yambms_proxy_total_voltage_low_alarm + internal: true + - platform: template + id: yambms_proxy_cell_temp_high_alarm + internal: true + - platform: template + id: yambms_proxy_cell_temp_low_alarm + internal: true + - platform: template + id: yambms_proxy_charge_overcurrent_alarm + internal: true + - platform: template + id: yambms_proxy_discharge_overcurrent_alarm + internal: true + - platform: template + id: yambms_proxy_cell_imbalance_alarm + internal: true + - platform: template + id: yambms_proxy_cell_voltage_high_alarm + internal: true + - platform: template + id: yambms_proxy_cell_voltage_low_alarm + internal: true + - platform: template + id: yambms_proxy_cell_overvoltage_protection + internal: true + - platform: template + id: yambms_proxy_cell_undervoltage_protection + internal: true + - platform: template + id: yambms_proxy_cell_overtemp_protection + internal: true + - platform: template + id: yambms_proxy_cell_undertemp_protection + internal: true + - platform: template + id: yambms_proxy_charge_overcurrent_protection + internal: true + - platform: template + id: yambms_proxy_discharge_overcurrent_protection + internal: true + - platform: template + id: yambms_proxy_system_fault_protection + internal: true + +interval: + - interval: 100ms + then: + - if: + condition: + lambda: 'return id(${rs485_id}_protocol).state == "Pylontech" && (id(${yambms_id}_bms_combined).state > 0);' + then: + - lambda: !lambda |- + // --- PROTOCOL ENABLED: Pass real data if available --- + // The .has_state() check prevents race conditions at startup. + if (id(${yambms_id}_battery_soc).has_state()) id(yambms_proxy_soc).publish_state(id(${yambms_id}_battery_soc).state); + if (id(${yambms_id}_total_voltage).has_state()) id(yambms_proxy_voltage).publish_state(id(${yambms_id}_total_voltage).state); + if (id(${yambms_id}_current).has_state()) id(yambms_proxy_current).publish_state(id(${yambms_id}_current).state); + if (id(${yambms_id}_max_temperature).has_state()) id(yambms_proxy_temperature).publish_state(id(${yambms_id}_max_temperature).state); + if (id(${yambms_id}_battery_soh).has_state()) id(yambms_proxy_soh).publish_state(id(${yambms_id}_battery_soh).state); + if (id(${yambms_id}_charging_cycles).has_state()) id(yambms_proxy_cycle_count).publish_state(id(${yambms_id}_charging_cycles).state); + if (id(${yambms_id}_max_cell_voltage).has_state()) id(yambms_proxy_max_cell_v).publish_state(id(${yambms_id}_max_cell_voltage).state); + if (id(${yambms_id}_min_cell_voltage).has_state()) id(yambms_proxy_min_cell_v).publish_state(id(${yambms_id}_min_cell_voltage).state); + if (id(${yambms_id}_max_temperature).has_state()) id(yambms_proxy_max_temp).publish_state(id(${yambms_id}_max_temperature).state); + if (id(${yambms_id}_min_temperature).has_state()) id(yambms_proxy_min_temp).publish_state(id(${yambms_id}_min_temperature).state); + if (id(${yambms_id}_requested_charge_voltage).has_state()) id(yambms_proxy_max_charge_v).publish_state(id(${yambms_id}_requested_charge_voltage).state); + if (id(${yambms_id}_requested_discharge_voltage).has_state()) id(yambms_proxy_min_discharge_v).publish_state(id(${yambms_id}_requested_discharge_voltage).state); + if (id(${yambms_id}_requested_charge_current).has_state()) id(yambms_proxy_max_charge_i).publish_state(id(${yambms_id}_requested_charge_current).state); + if (id(${yambms_id}_requested_discharge_current).has_state()) id(yambms_proxy_max_discharge_i).publish_state(id(${yambms_id}_requested_discharge_current).state); + // Binary Sensors (Alarms/Protections) + if (id(${yambms_id}_errors_bitmask_warning).has_state()) { + uint16_t mask = id(${yambms_id}_errors_bitmask_warning).state; + id(yambms_proxy_total_voltage_high_alarm).publish_state((mask & 0x0002) > 0); + id(yambms_proxy_total_voltage_low_alarm).publish_state((mask & 0x0004) > 0); + id(yambms_proxy_cell_temp_high_alarm).publish_state((mask & 0x0008) > 0); + id(yambms_proxy_cell_temp_low_alarm).publish_state((mask & 0x0010) > 0); + id(yambms_proxy_charge_overcurrent_alarm).publish_state((mask & 0x0100) > 0); + id(yambms_proxy_discharge_overcurrent_alarm).publish_state((mask & 0x0080) > 0); + id(yambms_proxy_cell_imbalance_alarm).publish_state((mask & 0x1000) > 0); + id(yambms_proxy_cell_voltage_high_alarm).publish_state((mask & 0x0002) > 0); + id(yambms_proxy_cell_voltage_low_alarm).publish_state((mask & 0x0004) > 0); + } + if (id(${yambms_id}_errors_bitmask_alarm).has_state()) { + uint16_t mask = id(${yambms_id}_errors_bitmask_alarm).state; + id(yambms_proxy_cell_overvoltage_protection).publish_state((mask & 0x0002) > 0); + id(yambms_proxy_cell_undervoltage_protection).publish_state((mask & 0x0004) > 0); + id(yambms_proxy_cell_overtemp_protection).publish_state((mask & 0x0008) > 0); + id(yambms_proxy_cell_undertemp_protection).publish_state((mask & 0x0010) > 0); + id(yambms_proxy_charge_overcurrent_protection).publish_state((mask & 0x0100) > 0); + id(yambms_proxy_discharge_overcurrent_protection).publish_state((mask & 0x0080) > 0); + id(yambms_proxy_system_fault_protection).publish_state((mask & 0x0800) > 0); + } + +pylontech_rs485: + uart_id: ${rs485_node_id} + update_timeout: ${rs485_update_timeout} + # --- Link to PROXY sensors --- + state_of_charge: yambms_proxy_soc + voltage: yambms_proxy_voltage + current: yambms_proxy_current + temperature: yambms_proxy_temperature + state_of_health: yambms_proxy_soh + cycle_count: yambms_proxy_cycle_count + max_cell_voltage: yambms_proxy_max_cell_v + min_cell_voltage: yambms_proxy_min_cell_v + max_temperature: yambms_proxy_max_temp + min_temperature: yambms_proxy_min_temp + mosfet_temperature: yambms_proxy_temperature + max_mosfet_temperature: yambms_proxy_max_temp + min_mosfet_temperature: yambms_proxy_min_temp + bms_temperature: yambms_proxy_temperature + max_bms_temperature: yambms_proxy_max_temp + min_bms_temperature: yambms_proxy_min_temp + total_voltage_high_alarm: yambms_proxy_total_voltage_high_alarm + total_voltage_low_alarm: yambms_proxy_total_voltage_low_alarm + cell_voltage_high_alarm: yambms_proxy_cell_voltage_high_alarm + cell_voltage_low_alarm: yambms_proxy_cell_voltage_low_alarm + cell_temp_high_alarm: yambms_proxy_cell_temp_high_alarm + cell_temp_low_alarm: yambms_proxy_cell_temp_low_alarm + charge_overcurrent_alarm: yambms_proxy_charge_overcurrent_alarm + discharge_overcurrent_alarm: yambms_proxy_discharge_overcurrent_alarm + cell_imbalance_alarm: yambms_proxy_cell_imbalance_alarm + cell_overvoltage_protection: yambms_proxy_cell_overvoltage_protection + cell_undervoltage_protection: yambms_proxy_cell_undervoltage_protection + cell_overtemp_protection: yambms_proxy_cell_overtemp_protection + cell_undertemp_protection: yambms_proxy_cell_undertemp_protection + charge_overcurrent_protection: yambms_proxy_charge_overcurrent_protection + discharge_overcurrent_protection: yambms_proxy_discharge_overcurrent_protection + system_fault_protection: yambms_proxy_system_fault_protection + max_voltage: yambms_proxy_max_charge_v + min_voltage: yambms_proxy_min_discharge_v + max_charge_current: yambms_proxy_max_charge_i + max_discharge_current: yambms_proxy_max_discharge_i \ No newline at end of file From 1597d99fccf43ba75b2786953e4d6f689479dd4b Mon Sep 17 00:00:00 2001 From: Fahmula Date: Sat, 12 Jul 2025 07:51:46 -0400 Subject: [PATCH 2/2] refactor: Refactor RS485 Pylontech integration Delete generic `board_options_itf_esp32_rs485.yaml` and replace its usage with `board_options_itf_uart_4.yaml` in the main configuration. Rename `yambms_rs485.yaml` to `yambms_rs485_pylon.yaml` to better reflect its specific use for Pylontech. Update the `rs485` package reference to `rs485_pylon` and introduce new variables (`rs485_name`, `rs485_uart_id`, `rs485_uart_baud_rate`) for more explicit configuration. Modify `yambms_rs485_pylon.yaml` to extend the UART configuration and use the new `rs485_uart_id` for the Pylontech component. This improves clarity and modularity. --- YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml | 22 ++++++---------- .../board/board_options_itf_esp32_rs485.yaml | 25 ------------------- ...bms_rs485.yaml => yambms_rs485_pylon.yaml} | 8 ++++-- 3 files changed, 14 insertions(+), 41 deletions(-) delete mode 100644 packages/board/board_options_itf_esp32_rs485.yaml rename packages/yambms/{yambms_rs485.yaml => yambms_rs485_pylon.yaml} (98%) diff --git a/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml b/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml index 011d5d7..ef57688 100644 --- a/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml +++ b/YamBMS_RP_JK-BLE_to_Pylontech-RS485.yaml @@ -177,17 +177,8 @@ packages: ref: main refresh: 0s files: - # UART 1 - # - path: 'packages/board/board_options_itf_uart_esp_1.yaml' - # UART 2 - # - path: 'packages/board/board_options_itf_uart_esp_2.yaml' - # UART 3 - # - path: 'packages/board/board_options_itf_uart_esp_3.yaml' - - # ESP32_RS485 (M5Stack RS485 base/unit) - - path: 'packages/board/board_options_itf_esp32_rs485.yaml' - vars: - rs485_node_id: 'rs485_inverter_1' + # UART 4 - M5Stack RS485 base (id: uart_4) + - path: 'packages/board/board_options_itf_uart_4.yaml' ############################################################ @@ -267,17 +258,20 @@ packages: files: - path: 'packages/yambms/yambms.yaml' - rs485: + rs485_pylon: url: https://github.com/Sleeper85/esphome-yambms ref: main refresh: 0s files: - - path: 'packages/yambms/yambms_rs485.yaml' + - path: 'packages/yambms/yambms_rs485_pylon.yaml' vars: rs485_id: 'rs485_1' - rs485_node_id: 'rs485_inverter_1' + rs485_name: 'RS485 1' + rs485_uart_id: 'uart_4' + rs485_uart_baud_rate: '9600' rs485_update_timeout: '5s' + # +--------------------------------------+ # | DEBUG ( logger level must be DEBUG ) | # +--------------------------------------+ diff --git a/packages/board/board_options_itf_esp32_rs485.yaml b/packages/board/board_options_itf_esp32_rs485.yaml deleted file mode 100644 index 11a5da5..0000000 --- a/packages/board/board_options_itf_esp32_rs485.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Updated : 2025.07.10 -# Version : 1.5.7 -# GitHub : https://github.com/Sleeper85/esphome-yambms - -# YamBMS ( Yet another multi-BMS Merging Solution ) - -# This YAML is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation, either version 3 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -uart: - - id: ${rs485_node_id} - tx_pin: ${tx_pin_4} - rx_pin: ${rx_pin_4} - baud_rate: 9600 - rx_buffer_size: 256 \ No newline at end of file diff --git a/packages/yambms/yambms_rs485.yaml b/packages/yambms/yambms_rs485_pylon.yaml similarity index 98% rename from packages/yambms/yambms_rs485.yaml rename to packages/yambms/yambms_rs485_pylon.yaml index 45fae77..adb1e86 100644 --- a/packages/yambms/yambms_rs485.yaml +++ b/packages/yambms/yambms_rs485_pylon.yaml @@ -21,9 +21,13 @@ external_components: - source: github://fahmula/esphome-pylontech-rs485@main refresh: 0s +uart: + - id: !extend ${rs485_uart_id} + baud_rate: ${rs485_uart_baud_rate} + select: - platform: template - name: "${name} RS485 Protocol" + name: "${name} ${rs485_name} Protocol" id: ${rs485_id}_protocol options: - "Pylontech" @@ -177,7 +181,7 @@ interval: } pylontech_rs485: - uart_id: ${rs485_node_id} + uart_id: ${rs485_uart_id} update_timeout: ${rs485_update_timeout} # --- Link to PROXY sensors --- state_of_charge: yambms_proxy_soc