From ac64ace3cdccda7a8dbf6fc892d265e096ddbb4c Mon Sep 17 00:00:00 2001 From: Sleeper85 Date: Thu, 19 Feb 2026 23:01:34 +0100 Subject: [PATCH] YamBMS basic blue display 1.1.2 HA and ESPHome version --- ...tions_display_lvgl_800x480_basic_blue.yaml | 1641 ++++++++--------- ...splay_lvgl_800x480_basic_blue_esphome.yaml | 22 + ...ns_display_lvgl_800x480_basic_blue_ha.yaml | 22 + ..._options_display_lvgl_esphome_sensors.yaml | 508 +++++ ...board_options_display_lvgl_ha_sensors.yaml | 551 ++++++ 5 files changed, 1864 insertions(+), 880 deletions(-) create mode 100644 packages/board/board_options_display_lvgl_800x480_basic_blue_esphome.yaml create mode 100644 packages/board/board_options_display_lvgl_800x480_basic_blue_ha.yaml create mode 100644 packages/board/board_options_display_lvgl_esphome_sensors.yaml create mode 100644 packages/board/board_options_display_lvgl_ha_sensors.yaml diff --git a/packages/board/board_options_display_lvgl_800x480_basic_blue.yaml b/packages/board/board_options_display_lvgl_800x480_basic_blue.yaml index 14e94ca..6414672 100644 --- a/packages/board/board_options_display_lvgl_800x480_basic_blue.yaml +++ b/packages/board/board_options_display_lvgl_800x480_basic_blue.yaml @@ -1,5 +1,5 @@ -# Updated : 2026.02.18 -# Version : 1.1.1 +# Updated : 2026.02.19 +# Version : 1.1.2 # GitHub : https://github.com/Sleeper85/esphome-yambms # YamBMS ( Yet another multi-BMS Merging Solution ) @@ -17,8 +17,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Board : ESP32-S3 WS Touch LCD 7" and 4.3" (800x480) -# Pages : Page 1 = Battery | Page 2 = Status +# +---------------------------------------------------------+ +# | Pages : Page 1 = Battery | Page 2 = Status | +# +---------------------------------------------------------+ # +---------------------------------------------------------+ # | Fonts | @@ -49,6 +50,7 @@ font: # +---------------------------------------------------------+ # | Display Timeout | # +---------------------------------------------------------+ + number: - platform: template id: display_timeout @@ -79,20 +81,24 @@ touchscreen: - lvgl.widget.redraw: - light.turn_on: backlight -# +---------------------------------------------------------+ -# | LVGL Configuration | + # +---------------------------------------------------------+ # | Color definitions (LVGL hex) | # +---------------------------------------------------------+ -# BG : 0x1a1a2e (dark navy) -# PANEL : 0x16213e (slightly lighter navy) -# ACCENT : 0x0f3460 (blue) -# GREEN : 0x00b894 -# YELLOW : 0xfdcb6e -# RED : 0xe17055 -# TEXT_WHITE : 0xffffff -# TEXT_GRAY : 0xb2bec3 +substitutions: + color_bg: '0x1a1a2e' # dark navy + color_panel: '0x16213e' # slightly lighter navy + color_1: '0xffffff' # white + color_2: '0xb2bec3' # grey + color_3: '0x0f3460' # blue + color_4: '0x74b9ff' # light_blue + color_5: '0x00b894' # green + color_6: '0xfdcb6e' # yellow + color_7: '0xe17055' # red +# +---------------------------------------------------------+ +# | LVGL Configuration | +# +---------------------------------------------------------+ lvgl: displays: - my_display @@ -108,7 +114,7 @@ lvgl: # Global style defaults theme: label: - text_color: 0xffffff + text_color: ${color_1} obj: pad_all: 0 scrollbar_mode: "off" @@ -118,1413 +124,1288 @@ lvgl: # └─────────────────────────────────────────────────────┘ pages: - id: page_battery - bg_color: 0x1a1a2e + bg_color: ${color_bg} widgets: # ── NAV BUTTONS (bottom-right, always visible) ─── - button: id: btn_p1 - x: 680 + x: 670 y: 440 width: 50 height: 32 - bg_color: 0x0f3460 + bg_color: ${color_3} border_width: 2 - border_color: 0x00b894 + border_color: ${color_5} radius: 6 widgets: - label: text: "P1" text_font: font_14 - text_color: 0x00b894 + text_color: ${color_5} align: CENTER on_click: - lvgl.page.show: page_battery - button: id: btn_p2 - x: 740 + x: 730 y: 440 width: 50 height: 32 - bg_color: 0x16213e + bg_color: ${color_panel} border_width: 1 - border_color: 0xb2bec3 + border_color: ${color_2} radius: 6 widgets: - label: text: "P2" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} align: CENTER on_click: - lvgl.page.show: page_status - # ── SOC BAR ─────────────────────────────────────── - # Container + + # ── ROW 1 : Faults Status | Battery SoC | Charge Status ──────── + + # Faults Status - obj: x: 20 - y: 8 - width: 760 - height: 106 - bg_color: 0x16213e + y: 10 + width: 245 + height: 150 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 8 pad_all: 0 + scrollbar_mode: "off" widgets: - label: x: 0 - y: 8 - width: 758 - text: "BATTERY SOC" + y: 5 + width: 100% + text: "Faults Status" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - - bar: - id: bar_soc - x: 12 - y: 34 - width: 608 - height: 48 - min_value: 0 - max_value: 100 - value: 0 - indicator: - bg_color: 0xfdcb6e - bg_color: 0x0f3460 + + # Row 1 + - obj: + id: net_network + x: 15 + y: 30 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "IP Network" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + - obj: + id: net_api_mqtt + x: 125 + y: 30 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "API/MQTT" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + + # Row 2 + - obj: + id: net_can_inv + x: 15 + y: 60 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "CAN INV" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + - obj: + id: net_rs485_inv + x: 125 + y: 60 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "RS485 INV" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + + # Row 3 + - obj: + id: bg_bms + x: 15 + y: 90 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "BMS" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + - obj: + id: bg_shunt + x: 125 + y: 90 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "Shunt" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + + # Row 4 + - obj: + id: bg_balancer + x: 15 + y: 120 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "Balancer" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + - obj: + id: bg_alarm + x: 125 + y: 120 + width: 100 + height: 20 + bg_color: ${color_4} + border_width: 0 + radius: 4 + scrollbar_mode: "off" + widgets: + - label: + width: 100% + text: "Alarm" + text_font: font_14 + text_color: ${color_bg} + text_align: CENTER + + # Battery SoC + - obj: + x: 275 + y: 10 + width: 250 + height: 150 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 8 + pad_all: 0 + scrollbar_mode: "off" + widgets: + - label: + x: 0 + y: 5 + width: 100% + text: "Battery SoC" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + + # Terminal + + - obj: + x: 60 + y: 30 + width: 10 + height: 5 + bg_color: ${color_2} + border_width: 0 + radius: 1 + scrollbar_mode: "off" + + # Battery + - obj: + x: 40 + y: 35 + width: 50 + height: 100 + bg_color: ${color_3} + border_width: 2 + border_color: ${color_2} + radius: 4 + pad_all: 0 + scrollbar_mode: "off" + widgets: + # SoC + - obj: + id: battery_fill_soc + x: 0 + y: 0 + width: 100% + height: 0 # SoC % + bg_color: ${color_6} + border_width: 0 + radius: 2 + align: BOTTOM_LEFT + scrollbar_mode: "off" + + # SoC text value - label: id: lbl_soc_value - x: 621 - y: 34 - width: 125 - height: 48 - text: "--.- %" + x: 120 + y: 60 + width: 100 + text: "---%" text_font: font_40 - text_color: 0xfdcb6e - text_align: RIGHT + text_color: ${color_1} - # ── ROW 1 : Voltage | Current | Power ───────────── - # Voltage panel + # Requested Values to Inverter - obj: - x: 20 - y: 126 - width: 240 - height: 105 - bg_color: 0x16213e + x: 535 + y: 10 + width: 245 + height: 150 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 - radius: 8 - widgets: - - label: - x: 0 - y: 8 - width: 238 - text: "VOLTAGE" - text_font: font_14 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_voltage - x: 0 - y: 34 - width: 238 - text: "--.- V" - text_font: font_40 - text_color: 0xffffff - text_align: CENTER - - # Current panel - - obj: - x: 280 - y: 126 - width: 240 - height: 105 - bg_color: 0x16213e - border_width: 1 - border_color: 0x0f3460 - radius: 8 - widgets: - - label: - x: 0 - y: 8 - width: 238 - text: "CURRENT" - text_font: font_14 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_current - x: 0 - y: 34 - width: 238 - text: "--.- A" - text_font: font_40 - text_color: 0xffffff - text_align: CENTER - - # Power panel - - obj: - x: 540 - y: 126 - width: 240 - height: 105 - bg_color: 0x16213e - border_width: 1 - border_color: 0x0f3460 - radius: 8 - widgets: - - label: - x: 0 - y: 8 - width: 238 - text: "POWER" - text_font: font_14 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_power - x: 0 - y: 34 - width: 238 - text: "---- W" - text_font: font_40 - text_color: 0xffffff - text_align: CENTER - - # ── ROW 2 : Capacity info (4 tiles) ─────────────── - # Installed Capacity - - obj: - x: 20 - y: 243 - width: 178 - height: 70 - bg_color: 0x16213e - border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% + text: "Requested Values to Inverter" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + # CVL + - label: + x: 15 + y: 30 + width: 50 + text: "CVL :" + text_font: font_18 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_req_cvl + x: 75 + y: 30 + width: 60 + text: "--.- V" + text_font: font_18 + text_color: ${color_5} + # CVL instruction + - label: + id: lbl_cvl_instruction + x: 145 + y: 30 + width: 90 + text: "---" + text_font: font_18 + text_color: ${color_4} + # CCL + - label: + x: 15 + y: 60 + width: 50 + text: "CCL :" + text_font: font_18 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_req_ccl + x: 75 + y: 60 + width: 60 + text: "--- A" + text_font: font_18 + text_color: ${color_5} + # CCL Derating + - label: + id: lbl_ccl_derating + x: 145 + y: 60 + width: 90 + text: "---" + text_font: font_18 + text_color: ${color_7} + # DCL + - label: + x: 15 + y: 90 + width: 50 + text: "DCL :" + text_font: font_18 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_req_dcl + x: 75 + y: 90 + width: 60 + text: "--- A" + text_font: font_18 + text_color: ${color_5} + # DCL Derating + - label: + id: lbl_dcl_derating + x: 145 + y: 90 + width: 90 + text: "---" + text_font: font_18 + text_color: ${color_4} + # DVL + - label: + x: 15 + y: 120 + width: 50 + text: "DVL :" + text_font: font_18 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_req_dvl + x: 75 + y: 120 + width: 60 + text: "--.- V" + text_font: font_18 + text_color: ${color_5} + # DVL instruction + - label: + id: lbl_dvl_instruction + x: 145 + y: 120 + width: 90 + text: "---" + text_font: font_18 + text_color: ${color_4} + + # ── ROW 2 : Voltage | Power | Current ─── + # Voltage + - obj: + x: 20 + y: 170 + width: 245 + height: 90 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 8 + pad_all: 0 + scrollbar_mode: "off" + widgets: + - label: + x: 0 + y: 5 + width: 100% + text: "VOLTAGE" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_voltage + x: 0 + y: 30 + width: 100% + text: "--.- V" + text_font: font_40 + text_color: ${color_1} + text_align: CENTER + + # Power + - obj: + x: 275 + y: 170 + width: 250 + height: 90 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 8 + pad_all: 0 + scrollbar_mode: "off" + widgets: + - label: + x: 0 + y: 5 + width: 100% + text: "POWER" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_power + x: 0 + y: 30 + width: 100% + text: "--- W" + text_font: font_40 + text_color: ${color_1} + text_align: CENTER + + # Current + - obj: + x: 535 + y: 170 + width: 245 + height: 90 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 8 + pad_all: 0 + scrollbar_mode: "off" + widgets: + - label: + x: 0 + y: 5 + width: 100% + text: "CURRENT" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_current + x: 0 + y: 30 + width: 100% + text: "--- A" + text_font: font_40 + text_color: ${color_1} + text_align: CENTER + + # ── ROW 3 : Capacity infos - SoH ── + # Installed Capacity + - obj: + x: 20 + y: 270 + width: 178 + height: 60 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 6 + widgets: + - label: + x: 0 + y: 5 + width: 100% text: "Installed Cap." text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_installed_cap x: 0 - y: 28 - width: 176 - text: "---- Ah" + y: 30 + width: 100% + text: "--- Ah" text_font: font_18 - text_color: 0xffffff + text_color: ${color_1} text_align: CENTER # Battery Capacity - obj: x: 208 - y: 243 + y: 270 width: 178 - height: 70 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Battery Cap." text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_battery_cap x: 0 - y: 28 - width: 176 - text: "---- Ah" + y: 30 + width: 100% + text: "--- Ah" text_font: font_18 - text_color: 0xffffff + text_color: ${color_1} text_align: CENTER # Capacity Remaining - obj: x: 396 - y: 243 + y: 270 width: 178 - height: 70 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Cap. Remaining" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_cap_remaining x: 0 - y: 28 - width: 176 - text: "---- Ah" + y: 30 + width: 100% + text: "--- Ah" text_font: font_18 - text_color: 0x00b894 + text_color: ${color_5} text_align: CENTER # SoH - obj: x: 584 - y: 243 + y: 270 width: 196 - height: 70 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 194 + y: 5 + width: 100% text: "Battery SoH" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_soh x: 0 - y: 28 - width: 194 - text: "--.- %" + y: 30 + width: 100% + text: "--- %" text_font: font_18 - text_color: 0x00b894 + text_color: ${color_5} text_align: CENTER - # ── ROW 3 : Cell voltages + Delta + Temperatures ── + # ── ROW 4 : Cell voltages + Delta + Temperatures ── # Max Cell V. - obj: x: 20 - y: 325 + y: 340 width: 178 - height: 105 - bg_color: 0x16213e + height: 90 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Max Cell V." text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_max_cell_v x: 0 - y: 28 - width: 176 + y: 30 + width: 100% text: "-.--- V" text_font: font_18 - text_color: 0xfdcb6e + text_color: ${color_7} text_align: CENTER - label: id: lbl_max_cell_num x: 0 - y: 54 - width: 176 + y: 55 + width: 100% text: "Cell ---" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER # Min Cell V. - obj: x: 208 - y: 325 + y: 340 width: 178 - height: 105 - bg_color: 0x16213e + height: 90 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Min Cell V." text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_min_cell_v x: 0 - y: 28 - width: 176 + y: 30 + width: 100% text: "-.--- V" text_font: font_18 - text_color: 0xfdcb6e + text_color: ${color_4} text_align: CENTER - label: id: lbl_min_cell_num x: 0 - y: 54 - width: 176 + y: 55 + width: 100% text: "Cell ---" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER # Delta Cell V. + Equalizing - obj: x: 396 - y: 325 + y: 340 width: 178 - height: 105 - bg_color: 0x16213e + height: 90 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Delta Cell V." text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_delta_cell x: 0 - y: 28 - width: 176 - text: "-.--- V" + y: 30 + width: 100% + text: "--- mV" text_font: font_18 - text_color: 0xffffff + text_color: ${color_5} text_align: CENTER - label: id: lbl_equalizing x: 0 - y: 54 - width: 176 - text: "Equalizing: --" + y: 55 + width: 100% + text: "Equalizing: ---" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER # Max/Min Temperature - obj: x: 584 - y: 325 + y: 340 width: 196 - height: 105 - bg_color: 0x16213e + height: 90 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 194 + y: 5 + width: 100% text: "Temperature" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_max_temp x: 0 - y: 28 + y: 30 width: 97 text: "↑ ---°C" text_font: font_18 - text_color: 0xe17055 + text_color: ${color_7} text_align: CENTER - label: id: lbl_min_temp x: 97 - y: 28 + y: 30 width: 97 text: "↓ ---°C" text_font: font_18 - text_color: 0x74b9ff + text_color: ${color_4} text_align: CENTER - label: id: lbl_max_temp_sensor x: 0 - y: 54 + y: 55 width: 97 text: "Sensor ---" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_min_temp_sensor x: 97 - y: 54 + y: 55 width: 97 text: "Sensor ---" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER # ┌─────────────────────────────────────────────────────┐ # │ PAGE 2 — STATUS │ # └─────────────────────────────────────────────────────┘ - id: page_status - bg_color: 0x1a1a2e + bg_color: ${color_bg} widgets: # ── NAV BUTTONS ─────────────────────────────────── - button: id: btn_p1_s - x: 680 + x: 670 y: 440 width: 50 height: 32 - bg_color: 0x16213e + bg_color: ${color_panel} border_width: 1 - border_color: 0xb2bec3 + border_color: ${color_2} radius: 6 widgets: - label: text: "P1" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} align: CENTER on_click: - lvgl.page.show: page_battery - button: id: btn_p2_s - x: 740 + x: 730 y: 440 width: 50 height: 32 - bg_color: 0x0f3460 + bg_color: ${color_3} border_width: 2 - border_color: 0x0984e3 + border_color: ${color_5} radius: 6 widgets: - label: text: "P2" text_font: font_14 - text_color: 0x0984e3 + text_color: ${color_5} align: CENTER on_click: - lvgl.page.show: page_status - # ── ROW 1 : Inverter comm | Board | Charging status | Last Complete Charge ── - # Inverter comm. - - obj: - x: 20 - y: 8 - width: 178 - height: 72 - bg_color: 0x16213e - border_width: 1 - border_color: 0x0f3460 - radius: 6 - widgets: - - label: - x: 0 - y: 4 - width: 176 - text: "Inverter Comm." - text_font: font_14 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_inv_comm - x: 0 - y: 28 - width: 176 - text: "---" - text_font: font_22 - text_color: 0xb2bec3 - text_align: CENTER - - # Board status - - obj: - x: 208 - y: 8 - width: 178 - height: 72 - bg_color: 0x16213e - border_width: 1 - border_color: 0x0f3460 - radius: 6 - widgets: - - label: - x: 0 - y: 4 - width: 176 - text: "Board Status" - text_font: font_14 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_board_status - x: 0 - y: 28 - width: 176 - text: "---" - text_font: font_22 - text_color: 0xb2bec3 - text_align: CENTER - + # ── ROW 1 : Charging status | Charge instruction | Discharge instruction | Last Complete Charge ── # Charging status - obj: - x: 396 - y: 8 + x: 20 + y: 10 width: 178 - height: 72 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 - text: "Charging Status" + y: 5 + width: 100% + text: "Charging status" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_charging_status x: 0 - y: 28 - width: 176 + y: 30 + width: 100% text: "---" - text_font: font_22 - text_color: 0xffffff + text_font: font_18 + text_color: ${color_5} + text_align: CENTER + + # Charge instruction + - obj: + x: 208 + y: 10 + width: 178 + height: 60 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 6 + widgets: + - label: + x: 0 + y: 5 + width: 100% + text: "Charge instruction" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_charge_instr + x: 0 + y: 30 + width: 100% + text: "---" + text_font: font_18 + text_color: ${color_4} + text_align: CENTER + + # Discharge instruction + - obj: + x: 396 + y: 10 + width: 178 + height: 60 + bg_color: ${color_panel} + border_width: 1 + border_color: ${color_3} + radius: 6 + widgets: + - label: + x: 0 + y: 5 + width: 100% + text: "Discharge instruction" + text_font: font_14 + text_color: ${color_2} + text_align: CENTER + - label: + id: lbl_discharge_instr + x: 0 + y: 30 + width: 100% + text: "---" + text_font: font_18 + text_color: ${color_7} text_align: CENTER # Last complete charge - obj: x: 584 - y: 8 + y: 10 width: 196 - height: 72 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 194 + y: 5 + width: 100% text: "Last Complete Charge" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_last_charge x: 0 - y: 28 - width: 194 + y: 30 + width: 100% text: "---" text_font: font_18 - text_color: 0xffffff + text_color: ${color_1} text_align: CENTER - # ── ROW 2 : Alarm | Warning | Charge Instr. | Discharge Instr. ── + # ── ROW 2 : Alarm | Warning | Free 1 | Free 2 ── # Alarm - obj: x: 20 - y: 92 + y: 80 width: 178 - height: 72 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Alarm" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_alarm x: 0 - y: 28 - width: 176 + y: 30 + width: 100% text: "---" - text_font: font_22 - text_color: 0xe17055 + text_font: font_18 + text_color: ${color_7} text_align: CENTER # Warning - obj: x: 208 - y: 92 + y: 80 width: 178 - height: 72 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 + y: 5 + width: 100% text: "Warning" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: id: lbl_warning x: 0 - y: 28 - width: 176 + y: 30 + width: 100% text: "---" - text_font: font_22 - text_color: 0xfdcb6e + text_font: font_18 + text_color: ${color_6} text_align: CENTER - # Charging Instruction + # Free_1 - obj: x: 396 - y: 92 + y: 80 width: 178 - height: 72 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 176 - text: "Charge Instr." + y: 5 + width: 100% + text: "Free 1" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: - id: lbl_charge_instr + id: lbl_free_1 x: 0 - y: 28 - width: 176 + y: 30 + width: 100% text: "---" - text_font: font_22 - text_color: 0x00b894 + text_font: font_18 + text_color: ${color_5} text_align: CENTER - # Discharging Instruction + # Free_2 - obj: x: 584 - y: 92 + y: 80 width: 196 - height: 72 - bg_color: 0x16213e + height: 60 + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 - width: 194 - text: "Discharge Instr." + y: 5 + width: 100% + text: "Free 2" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: - id: lbl_discharge_instr + id: x: 0 - y: 28 - width: 194 + y: 30 + width: 100% text: "---" - text_font: font_22 - text_color: 0x00b894 + text_font: font_18 + text_color: ${color_5} text_align: CENTER - # ── ROW 3 : BMS counters | Shunt counters | Uptime | Version ── + # ── ROW 4 : BMS counters | Shunt counters | Uptime | Version ── # BMS info panel - obj: x: 20 - y: 176 + y: 260 width: 190 height: 170 - bg_color: 0x16213e + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 + y: 5 width: 188 text: "BMS" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: x: 12 y: 26 text: "Count:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_bms_count x: 160 y: 26 text: "--" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 48 text: "Combined:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_bms_combined x: 160 y: 48 text: "--" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 70 text: "Blocking charge:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_bms_blk_chg x: 160 y: 70 text: "--" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 92 text: "Blocking discharge:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_bms_blk_dchg x: 160 y: 92 text: "--" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 114 text: "In alarm:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_bms_alarm x: 160 y: 114 text: "--" text_font: font_14 - text_color: 0xe17055 + text_color: ${color_7} # Shunt - obj: x: 220 - y: 176 + y: 260 width: 190 height: 170 - bg_color: 0x16213e + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 + y: 5 width: 188 text: "Shunt" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: x: 12 y: 26 text: "Shunt count:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_shunt_count x: 160 y: 26 text: "--" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 48 text: "Shunt combined:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_shunt_combined x: 160 y: 48 text: "--" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} # System - obj: x: 420 - y: 176 + y: 260 width: 360 height: 170 - bg_color: 0x16213e + bg_color: ${color_panel} border_width: 1 - border_color: 0x0f3460 + border_color: ${color_3} radius: 6 widgets: - label: x: 0 - y: 4 + y: 5 width: 358 text: "System" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} text_align: CENTER - label: x: 12 y: 26 text: "CCL Der. Reason:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_ccl_derating_reason x: 160 y: 26 - text: "--" + text: "---" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 48 text: "DCL Der. Reason:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_dcl_derating_reason x: 160 y: 48 - text: "--" + text: "---" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} # # one line free (y: 70) # - label: x: 12 y: 92 - text: "Board Uptime:" + text: "YamBMS Uptime:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_uptime x: 160 y: 92 text: "---" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 114 text: "ESPHome version:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_esphome_ver x: 160 y: 114 text: "---" text_font: font_14 - text_color: 0xffffff + text_color: ${color_1} - label: x: 12 y: 136 text: "YamBMS version:" text_font: font_14 - text_color: 0xb2bec3 + text_color: ${color_2} - label: id: lbl_yambms_ver x: 160 y: 136 text: "---" text_font: font_14 - text_color: 0xffffff - - # ── ROW 4 : Requested Values (inverter) ─────────── - - obj: - x: 20 - y: 358 - width: 760 - height: 72 - bg_color: 0x16213e - border_width: 1 - border_color: 0x0f3460 - radius: 6 - widgets: - - label: - x: 0 - y: 4 - width: 758 - text: "Requested Values to Inverter" - text_font: font_14 - text_color: 0xb2bec3 - text_align: CENTER - # Charge Voltage - - label: - x: 0 - y: 28 - width: 94 - text: "CVL:" - text_font: font_18 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_req_cvl - x: 94 - y: 28 - width: 94 - text: "--.- V" - text_font: font_18 - text_color: 0x00b894 - text_align: LEFT - # Charge Current - - label: - x: 188 - y: 28 - width: 94 - text: "CCL:" - text_font: font_18 - text_color: 0xb2bec3 - text_align: CENTER - - label: - id: lbl_req_ccl - x: 282 - y: 28 - width: 94 - text: "--- A" - text_font: font_18 - text_color: 0x00b894 - text_align: LEFT - # Discharge Voltage - - label: - x: 376 - y: 28 - width: 94 - text: "DVL:" - text_font: font_18 - text_color: 0xb2bec3 - text_align: RIGHT - - label: - id: lbl_req_dvl - x: 470 - y: 28 - width: 94 - text: "--.- V" - text_font: font_18 - text_color: 0x74b9ff - text_align: CENTER - # Discharge Current - - label: - x: 564 - y: 28 - width: 94 - text: "DCL:" - text_font: font_18 - text_color: 0xb2bec3 - text_align: RIGHT - - label: - id: lbl_req_dcl - x: 658 - y: 28 - width: 94 - text: "--- A" - text_font: font_18 - text_color: 0x74b9ff - text_align: CENTER - -# +---------------------------------------------------------+ -# | Sensor → LVGL bindings | -# +---------------------------------------------------------+ - -sensor: - - # ── PAGE 1 - BATTERY ── - - - platform: template - id: !extend ${yambms_id}_total_voltage - on_value: - then: - - lvgl.label.update: - id: lbl_voltage - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_current - on_value: - then: - - lvgl.label.update: - id: lbl_current - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f A", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_power - on_value: - then: - - lvgl.label.update: - id: lbl_power - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f W", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_installed_battery_capacity - on_value: - then: - - lvgl.label.update: - id: lbl_installed_cap - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_battery_capacity - on_value: - then: - - lvgl.label.update: - id: lbl_battery_cap - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_battery_capacity_remaining - on_value: - then: - - lvgl.label.update: - id: lbl_cap_remaining - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f Ah", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_battery_soc - on_value: - then: - - lvgl.label.update: - id: lbl_soc_value - text: !lambda 'return to_string((int)x) + " %";' - - lvgl.bar.update: - id: bar_soc - value: !lambda 'return (int)x;' - - - platform: template - id: !extend ${yambms_id}_battery_soh - on_value: - then: - - lvgl.label.update: - id: lbl_soh - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f %%", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_max_cell_voltage - on_value: - then: - - lvgl.label.update: - id: lbl_max_cell_v - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_max_voltage_cell - on_value: - then: - - lvgl.label.update: - id: lbl_max_cell_num - text: !lambda 'return "Cell " + to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_min_cell_voltage - on_value: - then: - - lvgl.label.update: - id: lbl_min_cell_v - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_min_voltage_cell - on_value: - then: - - lvgl.label.update: - id: lbl_min_cell_num - text: !lambda 'return "Cell " + to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_delta_cell_voltage - on_value: - then: - - lvgl.label.update: - id: lbl_delta_cell - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_max_temperature - on_value: - then: - - lvgl.label.update: - id: lbl_max_temp - text: !lambda 'char buf[12]; snprintf(buf, 12, "↑ %.1f°C", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_max_temperature_sensor - on_value: - then: - - lvgl.label.update: - id: lbl_max_temp_sensor - text: !lambda 'return "Sensor " + to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_min_temperature - on_value: - then: - - lvgl.label.update: - id: lbl_min_temp - text: !lambda 'char buf[12]; snprintf(buf, 12, "↓ %.1f°C", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_min_temperature_sensor - on_value: - then: - - lvgl.label.update: - id: lbl_min_temp_sensor - text: !lambda 'return "Sensor " + to_string((int)x);' - - # ── PAGE 2 - STATUS ── - - - platform: template - id: !extend ${yambms_id}_bms_count - on_value: - then: - - lvgl.label.update: - id: lbl_bms_count - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_bms_combined - on_value: - then: - - lvgl.label.update: - id: lbl_bms_combined - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_bms_blocking_charge - on_value: - then: - - lvgl.label.update: - id: lbl_bms_blk_chg - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_bms_blocking_discharge - on_value: - then: - - lvgl.label.update: - id: lbl_bms_blk_dchg - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_errors_bitmask_counter - on_value: - then: - - lvgl.label.update: - id: lbl_bms_alarm - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_shunt_count - on_value: - then: - - lvgl.label.update: - id: lbl_shunt_count - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_shunt_combined - on_value: - then: - - lvgl.label.update: - id: lbl_shunt_combined - text: !lambda 'return to_string((int)x);' - - - platform: template - id: !extend ${yambms_id}_requested_charge_voltage - on_value: - then: - - lvgl.label.update: - id: lbl_req_cvl - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_requested_charge_current - on_value: - then: - - lvgl.label.update: - id: lbl_req_ccl - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_requested_discharge_voltage - on_value: - then: - - lvgl.label.update: - id: lbl_req_dvl - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' - - - platform: template - id: !extend ${yambms_id}_requested_discharge_current - on_value: - then: - - lvgl.label.update: - id: lbl_req_dcl - text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' - -text_sensor: - - - platform: template - id: !extend ${yambms_id}_charging_status - on_value: - then: - - lvgl.label.update: - id: lbl_charging_status - text: !lambda 'return x;' - - - platform: template - id: !extend ${yambms_id}_eoc_timestamp_human - on_value: - then: - - lvgl.label.update: - id: lbl_last_charge - text: !lambda 'return x;' - - - platform: template - id: !extend ${yambms_id}_alarm - on_value: - then: - - lvgl.label.update: - id: lbl_alarm - text: !lambda 'return x;' - - - platform: template - id: !extend ${yambms_id}_warning - on_value: - then: - - lvgl.label.update: - id: lbl_warning - text: !lambda 'return x;' - - - platform: template - id: !extend ${yambms_id}_charging_instruction - on_value: - then: - - lvgl.label.update: - id: lbl_charge_instr - text: !lambda 'return x;' - - - platform: template - id: !extend ${yambms_id}_ccl_derating_reason - on_value: - then: - - lvgl.label.update: - id: lbl_ccl_derating_reason - text: !lambda 'return x;' - - - platform: template - id: !extend ${yambms_id}_dcl_derating_reason - on_value: - then: - - lvgl.label.update: - id: lbl_dcl_derating_reason - text: !lambda 'return x;' - - - platform: template - id: !extend esp32_uptime - on_value: - then: - - lvgl.label.update: - id: lbl_uptime - text: !lambda 'return x;' - - - platform: version - id: !extend esp32_esphome_version - on_value: - then: - - lvgl.label.update: - id: lbl_esphome_ver - text: !lambda 'return x.substr(0, 8);' - - - platform: template - id: !extend ${yambms_id}_running_version - on_value: - then: - - lvgl.label.update: - id: lbl_yambms_ver - text: !lambda 'return x;' - -binary_sensor: - - platform: template - id: !extend ${yambms_id}_equalizing - on_state: - then: - - lvgl.label.update: - id: lbl_equalizing - text: !lambda 'return std::string("Equalizing: ") + (x ? "ON" : "OFF");' - text_color: !lambda 'return x ? lv_color_hex(0xfdcb6e) : lv_color_hex(0xb2bec3);' - - - platform: template - id: !extend inverter_com_status - on_state: - then: - - lvgl.label.update: - id: lbl_inv_comm - text: !lambda 'return std::string(x ? "ONLINE" : "OFFLINE");' - text_color: !lambda 'return x ? lv_color_hex(0x00b894) : lv_color_hex(0xe17055);' - - - platform: status - id: !extend esp32_online_status - on_state: - then: - - lvgl.label.update: - id: lbl_board_status - text: !lambda 'return std::string(x ? "ONLINE" : "OFFLINE");' - text_color: !lambda 'return x ? lv_color_hex(0x00b894) : lv_color_hex(0xe17055);' - - - platform: template - id: !extend ${yambms_id}_discharging_instruction - on_state: - then: - - lvgl.label.update: - id: lbl_discharge_instr - text: !lambda 'return std::string(x ? "ALLOWED" : "BLOCKED");' - text_color: !lambda 'return x ? lv_color_hex(0x00b894) : lv_color_hex(0xe17055);' \ No newline at end of file + text_color: ${color_1} diff --git a/packages/board/board_options_display_lvgl_800x480_basic_blue_esphome.yaml b/packages/board/board_options_display_lvgl_800x480_basic_blue_esphome.yaml new file mode 100644 index 0000000..44bc7c8 --- /dev/null +++ b/packages/board/board_options_display_lvgl_800x480_basic_blue_esphome.yaml @@ -0,0 +1,22 @@ +# Updated : 2026.02.19 +# Version : 1.1.1 +# 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 . + +packages: + lvgl_display: !include board_options_display_lvgl_800x480_basic_blue.yaml + esphome_sensors: !include board_options_display_lvgl_esphome_sensors.yaml diff --git a/packages/board/board_options_display_lvgl_800x480_basic_blue_ha.yaml b/packages/board/board_options_display_lvgl_800x480_basic_blue_ha.yaml new file mode 100644 index 0000000..963c8c1 --- /dev/null +++ b/packages/board/board_options_display_lvgl_800x480_basic_blue_ha.yaml @@ -0,0 +1,22 @@ +# Updated : 2026.02.19 +# Version : 1.1.1 +# 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 . + +packages: + lvgl_display: !include board_options_display_lvgl_800x480_basic_blue.yaml + ha_sensors: !include board_options_display_lvgl_ha_sensors.yaml diff --git a/packages/board/board_options_display_lvgl_esphome_sensors.yaml b/packages/board/board_options_display_lvgl_esphome_sensors.yaml new file mode 100644 index 0000000..a1f5188 --- /dev/null +++ b/packages/board/board_options_display_lvgl_esphome_sensors.yaml @@ -0,0 +1,508 @@ +# Updated : 2026.02.19 +# Version : 1.1.1 +# 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 ESPHome Sensors → LVGL bindings | +# +---------------------------------------------------------+ + +sensor: + + - platform: template + id: !extend ${yambms_id}_total_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_voltage + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_current + on_value: + then: + - lvgl.label.update: + id: lbl_current + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_power + on_value: + then: + - lvgl.label.update: + id: lbl_power + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f W", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_installed_battery_capacity + on_value: + then: + - lvgl.label.update: + id: lbl_installed_cap + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_battery_capacity + on_value: + then: + - lvgl.label.update: + id: lbl_battery_cap + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_battery_capacity_remaining + on_value: + then: + - lvgl.label.update: + id: lbl_cap_remaining + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_battery_soc + on_value: + then: + - lvgl.label.update: + id: lbl_soc_value + text: !lambda 'return to_string((int)x) + "%";' + - lvgl.obj.update: + id: battery_fill_soc + height: !lambda 'return (int)x;' + bg_color: !lambda |- + if (x > 80) return lv_color_hex(${color_5}); // green + if (x > 20) return lv_color_hex(${color_6}); // yellow + return lv_color_hex(${color_7}); // red + + - platform: template + id: !extend ${yambms_id}_battery_soh + on_value: + then: + - lvgl.label.update: + id: lbl_soh + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f %%", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_max_cell_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_max_cell_v + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_max_voltage_cell + on_value: + then: + - lvgl.label.update: + id: lbl_max_cell_num + text: !lambda 'return "Cell " + to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_min_cell_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_min_cell_v + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_min_voltage_cell + on_value: + then: + - lvgl.label.update: + id: lbl_min_cell_num + text: !lambda 'return "Cell " + to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_delta_cell_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_delta_cell + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f mV", x * 1000); return buf;' + + - platform: template + id: !extend ${yambms_id}_max_temperature + on_value: + then: + - lvgl.label.update: + id: lbl_max_temp + text: !lambda 'char buf[12]; snprintf(buf, 12, "↑ %.1f°C", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_max_temperature_sensor + on_value: + then: + - lvgl.label.update: + id: lbl_max_temp_sensor + text: !lambda 'return "Sensor " + to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_min_temperature + on_value: + then: + - lvgl.label.update: + id: lbl_min_temp + text: !lambda 'char buf[12]; snprintf(buf, 12, "↓ %.1f°C", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_min_temperature_sensor + on_value: + then: + - lvgl.label.update: + id: lbl_min_temp_sensor + text: !lambda 'return "Sensor " + to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_bms_count + on_value: + then: + - lvgl.label.update: + id: lbl_bms_count + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_bms_combined + on_value: + then: + - lvgl.label.update: + id: lbl_bms_combined + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_bms_blocking_charge + on_value: + then: + - lvgl.label.update: + id: lbl_bms_blk_chg + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_bms_blocking_discharge + on_value: + then: + - lvgl.label.update: + id: lbl_bms_blk_dchg + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_errors_bitmask_counter + on_value: + then: + - lvgl.label.update: + id: lbl_bms_alarm + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_shunt_count + on_value: + then: + - lvgl.label.update: + id: lbl_shunt_count + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_shunt_combined + on_value: + then: + - lvgl.label.update: + id: lbl_shunt_combined + text: !lambda 'return to_string((int)x);' + + - platform: template + id: !extend ${yambms_id}_requested_charge_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_req_cvl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_requested_charge_current + on_value: + then: + - lvgl.label.update: + id: lbl_req_ccl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_requested_discharge_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_req_dvl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' + + - platform: template + id: !extend ${yambms_id}_requested_discharge_current + on_value: + then: + - lvgl.label.update: + id: lbl_req_dcl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' + +text_sensor: + + - platform: template + id: !extend ${yambms_id}_charging_status + on_value: + then: + - lvgl.label.update: + id: lbl_charging_status + text: !lambda 'return x;' + + - platform: template + id: !extend ${yambms_id}_eoc_timestamp_human + on_value: + then: + - lvgl.label.update: + id: lbl_last_charge + text: !lambda 'return x;' + + - platform: template + id: !extend ${yambms_id}_alarm + on_value: + then: + - lvgl.label.update: + id: lbl_alarm + text: !lambda 'return x;' + - lambda: |- + // Update bg_alarm based on alarm and warning status + lv_color_t color; + + if (x != "NoAlarm" && x != "Warning") { + color = lv_color_hex(${color_7}); // red if alarm + } else if (id(${yambms_id}_warning).state != "NoAlarm") { + color = lv_color_hex(${color_6}); // yellow if warning + } else { + color = lv_color_hex(${color_5}); // green if all OK + } + + lv_obj_set_style_bg_color(id(bg_alarm), color, 0); + + - platform: template + id: !extend ${yambms_id}_warning + on_value: + then: + - lvgl.label.update: + id: lbl_warning + text: !lambda 'return x;' + - lambda: |- + // Update bg_alarm based on alarm and warning status + lv_color_t color; + auto alarm = id(${yambms_id}_alarm).state; + if (alarm != "NoAlarm" && alarm != "Warning") { + color = lv_color_hex(${color_7}); // red if alarm + } else if (x != "NoAlarm") { + color = lv_color_hex(${color_6}); // yellow if warning + } else { + color = lv_color_hex(${color_5}); // green if all OK + } + + lv_obj_set_style_bg_color(id(bg_alarm), color, 0); + + - platform: template + id: !extend ${yambms_id}_charging_instruction + on_value: + then: + - lvgl.label.update: + id: lbl_charge_instr + text: !lambda 'return x;' + text_color: !lambda |- + if (x == "Stop") { + return lv_color_hex(${color_7}); // red + } else { + return lv_color_hex(${color_4}); // light blue + } + - lvgl.label.update: + id: lbl_cvl_instruction + text: !lambda 'return x;' + text_color: !lambda |- + if (x == "Stop") { + return lv_color_hex(${color_7}); // red + } else { + return lv_color_hex(${color_4}); // light blue + } + + - platform: template + id: !extend ${yambms_id}_ccl_derating_reason + on_value: + then: + - lvgl.label.update: + id: lbl_ccl_derating_reason + text: !lambda 'return x;' + - lvgl.label.update: + id: lbl_ccl_derating + text: !lambda |- + if (x == "No Derating") { + return std::string("No Der."); + } else { + return std::string("Derating"); + } + text_color: !lambda |- + if (x == "No Derating") { + return lv_color_hex(${color_4}); // light blue + } else { + return lv_color_hex(${color_7}); // red + } + + - platform: template + id: !extend ${yambms_id}_dcl_derating_reason + on_value: + then: + - lvgl.label.update: + id: lbl_dcl_derating_reason + text: !lambda 'return x;' + - lvgl.label.update: + id: lbl_dcl_derating + text: !lambda |- + if (x == "No Derating") { + return std::string("No Der."); + } else { + return std::string("Derating"); + } + text_color: !lambda |- + if (x == "No Derating") { + return lv_color_hex(${color_4}); // light blue + } else { + return lv_color_hex(${color_7}); // red + } + + - platform: template + id: !extend esp32_uptime + on_value: + then: + - lvgl.label.update: + id: lbl_uptime + text: !lambda 'return x;' + + - platform: version + id: !extend esp32_esphome_version + on_value: + then: + - lvgl.label.update: + id: lbl_esphome_ver + text: !lambda 'return x.substr(0, 8);' + + - platform: template + id: !extend ${yambms_id}_running_version + on_value: + then: + - lvgl.label.update: + id: lbl_yambms_ver + text: !lambda 'return x;' + + + - platform: template + id: !extend sys_fault_data + on_value: + then: + - lambda: |- + // Parse JSON array: [[0],[0,0,0],[0],[],[0],[],[0],...] + // Index: 0=API/MQTT, 1=BMS, 2=CAN, 3=RS485, 4=Shunt, 5=Bal, 6=Net + + // Manual parsing since root is an array + if (x.empty() || x[0] != '[') { + ESP_LOGE("fault", "Invalid JSON format"); + return; + } + + // Helper to count faults in a device array + auto count_faults = [](const std::string& json_str, int dev_idx) -> std::pair { + // Returns {nok_count, total_count} + // Very simple parser - looks for [X,Y,Z] at device index + + int bracket_count = 0; + int current_dev = -1; + int nok = 0; + int total = 0; + bool in_array = false; + + for (size_t i = 0; i < json_str.length(); i++) { + if (json_str[i] == '[') { + bracket_count++; + if (bracket_count == 2) { + current_dev++; + in_array = true; + nok = 0; + total = 0; + } + } else if (json_str[i] == ']') { + bracket_count--; + if (bracket_count == 1 && in_array && current_dev == dev_idx) { + return {nok, total}; + } + in_array = false; + } else if (in_array && current_dev == dev_idx && (json_str[i] == '0' || json_str[i] == '1')) { + total++; + if (json_str[i] == '1') nok++; + } + } + + return {-1, 0}; // device not found or empty + }; + + // Helper to determine color based on status + auto get_status_color = [](int nok, int total) -> lv_color_t { + if (nok == -1 || total == 0) { + return lv_color_hex(${color_4}); // light blue = absent + } else if (nok > 0) { + return lv_color_hex(${color_7}); // red = NOK + } else { + return lv_color_hex(${color_5}); // green = OK + } + }; + + // Update single device status + auto update_device = [&](lv_obj_t* obj, int idx) { + auto [nok, total] = count_faults(x, idx); + lv_color_t color = get_status_color(nok, total); + lv_obj_set_style_bg_color(obj, color, 0); + }; + + // Update all fault status widgets + update_device(id(net_network), 6); // Network + update_device(id(net_api_mqtt), 0); // API/MQTT + update_device(id(net_can_inv), 2); // CAN->INV + update_device(id(net_rs485_inv), 3); // RS485->INV + update_device(id(bg_bms), 1); // BMS + update_device(id(bg_shunt), 4); // Shunt + update_device(id(bg_balancer), 5); // Balancer + +binary_sensor: + - platform: template + id: !extend ${yambms_id}_equalizing + trigger_on_initial_state: true + on_state: + then: + - lvgl.label.update: + id: lbl_equalizing + text: !lambda 'return std::string("Equalizing: ") + (x ? "ON" : "OFF");' + text_color: !lambda 'return x ? lv_color_hex(${color_6}) : lv_color_hex(${color_2});' + + - platform: template + id: !extend ${yambms_id}_discharging_instruction + trigger_on_initial_state: true + on_state: + then: + - lvgl.label.update: + id: lbl_discharge_instr + text: !lambda 'return std::string(x ? "Allowed" : "Blocked");' + text_color: !lambda 'return x ? lv_color_hex(${color_4}) : lv_color_hex(${color_7});' + - lvgl.label.update: + id: lbl_dvl_instruction + text: !lambda 'return std::string(x ? "Allowed" : "Blocked");' + text_color: !lambda 'return x ? lv_color_hex(${color_4}) : lv_color_hex(${color_7});' diff --git a/packages/board/board_options_display_lvgl_ha_sensors.yaml b/packages/board/board_options_display_lvgl_ha_sensors.yaml new file mode 100644 index 0000000..8ecb477 --- /dev/null +++ b/packages/board/board_options_display_lvgl_ha_sensors.yaml @@ -0,0 +1,551 @@ +# Updated : 2026.02.19 +# Version : 1.1.1 +# 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 Home Assistant Sensors → LVGL bindings | +# +---------------------------------------------------------+ + +substitutions: + entity_prefix: 'yambms' + +sensor: + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_total_voltage + id: ha_total_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_voltage + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_current + id: ha_current + on_value: + then: + - lvgl.label.update: + id: lbl_current + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_power + id: ha_power + on_value: + then: + - lvgl.label.update: + id: lbl_power + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f W", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_installed_battery_capacity + id: ha_installed_battery_capacity + on_value: + then: + - lvgl.label.update: + id: lbl_installed_cap + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_battery_capacity + id: ha_battery_capacity + on_value: + then: + - lvgl.label.update: + id: lbl_battery_cap + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_capacity_remaining + id: ha_capacity_remaining + on_value: + then: + - lvgl.label.update: + id: lbl_cap_remaining + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f Ah", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_battery_soc + id: ha_battery_soc + on_value: + then: + - lvgl.label.update: + id: lbl_soc_value + text: !lambda 'return to_string((int)x) + "%";' + - lvgl.obj.update: + id: battery_fill_soc + height: !lambda 'return (int)x;' + bg_color: !lambda |- + if (x > 80) return lv_color_hex(${color_5}); // green + if (x > 20) return lv_color_hex(${color_6}); // yellow + return lv_color_hex(${color_7}); // red + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_battery_soh + id: ha_battery_soh + on_value: + then: + - lvgl.label.update: + id: lbl_soh + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f %%", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_max_cell_voltage + id: ha_max_cell_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_max_cell_v + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_max_voltage_cell + id: ha_max_voltage_cell + on_value: + then: + - lvgl.label.update: + id: lbl_max_cell_num + text: !lambda 'return "Cell " + to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_min_cell_voltage + id: ha_min_cell_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_min_cell_v + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.3f V", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_min_voltage_cell + id: ha_min_voltage_cell + on_value: + then: + - lvgl.label.update: + id: lbl_min_cell_num + text: !lambda 'return "Cell " + to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_delta_cell_voltage + id: ha_delta_cell_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_delta_cell + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f mV", x * 1000); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_max_temperature + id: ha_max_temperature + on_value: + then: + - lvgl.label.update: + id: lbl_max_temp + text: !lambda 'char buf[12]; snprintf(buf, 12, "↑ %.1f°C", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_max_temperature_sensor + id: ha_max_temperature_sensor + on_value: + then: + - lvgl.label.update: + id: lbl_max_temp_sensor + text: !lambda 'return "Sensor " + to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_min_temperature + id: ha_min_temperature + on_value: + then: + - lvgl.label.update: + id: lbl_min_temp + text: !lambda 'char buf[12]; snprintf(buf, 12, "↓ %.1f°C", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_min_temperature_sensor + id: ha_min_temperature_sensor + on_value: + then: + - lvgl.label.update: + id: lbl_min_temp_sensor + text: !lambda 'return "Sensor " + to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_bms_count + id: ha_bms_count + on_value: + then: + - lvgl.label.update: + id: lbl_bms_count + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_bms_combined + id: ha_bms_combined + on_value: + then: + - lvgl.label.update: + id: lbl_bms_combined + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_bms_blocking_charge + id: ha_bms_blocking_charge + on_value: + then: + - lvgl.label.update: + id: lbl_bms_blk_chg + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_bms_blocking_discharge + id: ha_bms_blocking_discharge + on_value: + then: + - lvgl.label.update: + id: lbl_bms_blk_dchg + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_bms_in_alarm + id: ha_bms_in_alarm + on_value: + then: + - lvgl.label.update: + id: lbl_bms_alarm + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_shunt_count + id: ha_shunt_count + on_value: + then: + - lvgl.label.update: + id: lbl_shunt_count + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_shunt_combined + id: ha_shunt_combined + on_value: + then: + - lvgl.label.update: + id: lbl_shunt_combined + text: !lambda 'return to_string((int)x);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_requested_charge_voltage + id: ha_requested_charge_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_req_cvl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_requested_charge_current + id: ha_requested_charge_current + on_value: + then: + - lvgl.label.update: + id: lbl_req_ccl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_requested_discharge_voltage + id: ha_requested_discharge_voltage + on_value: + then: + - lvgl.label.update: + id: lbl_req_dvl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.1f V", x); return buf;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_requested_discharge_current + id: ha_requested_discharge_current + on_value: + then: + - lvgl.label.update: + id: lbl_req_dcl + text: !lambda 'char buf[16]; snprintf(buf, 16, "%.0f A", x); return buf;' + +text_sensor: + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_charging_status + id: ha_charging_status + on_value: + then: + - lvgl.label.update: + id: lbl_charging_status + text: !lambda 'return x;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_last_complete_charge + id: ha_last_complete_charge + on_value: + then: + - lvgl.label.update: + id: lbl_last_charge + text: !lambda 'return x;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_alarm + id: ha_alarm + on_value: + then: + - lvgl.label.update: + id: lbl_alarm + text: !lambda 'return x;' + - lambda: |- + // Update bg_alarm based on alarm and warning status + lv_color_t color; + + if (x != "NoAlarm" && x != "Warning") { + color = lv_color_hex(${color_7}); // red if alarm + } else if (id(ha_warning).state != "NoAlarm") { + color = lv_color_hex(${color_6}); // yellow if warning + } else { + color = lv_color_hex(${color_5}); // green if all OK + } + + lv_obj_set_style_bg_color(id(bg_alarm), color, 0); + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_warning + id: ha_warning + on_value: + then: + - lvgl.label.update: + id: lbl_warning + text: !lambda 'return x;' + - lambda: |- + // Update bg_alarm based on alarm and warning status + lv_color_t color; + auto alarm = id(ha_alarm).state; + if (alarm != "NoAlarm" && alarm != "Warning") { + color = lv_color_hex(${color_7}); // red if alarm + } else if (x != "NoAlarm") { + color = lv_color_hex(${color_6}); // yellow if warning + } else { + color = lv_color_hex(${color_5}); // green if all OK + } + + lv_obj_set_style_bg_color(id(bg_alarm), color, 0); + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_charging_instruction + id: ha_charging_instruction + on_value: + then: + - lvgl.label.update: + id: lbl_charge_instr + text: !lambda 'return x;' + text_color: !lambda |- + if (x == "Stop") { + return lv_color_hex(${color_7}); // red + } else { + return lv_color_hex(${color_4}); // light blue + } + - lvgl.label.update: + id: lbl_cvl_instruction + text: !lambda 'return x;' + text_color: !lambda |- + if (x == "Stop") { + return lv_color_hex(${color_7}); // red + } else { + return lv_color_hex(${color_4}); // light blue + } + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_ccl_derating_reason + id: ha_ccl_derating_reason + on_value: + then: + - lvgl.label.update: + id: lbl_ccl_derating_reason + text: !lambda 'return x;' + - lvgl.label.update: + id: lbl_ccl_derating + text: !lambda |- + if (x == "No Derating") { + return std::string("No Der."); + } else { + return std::string("Derating"); + } + text_color: !lambda |- + if (x == "No Derating") { + return lv_color_hex(${color_4}); // light blue + } else { + return lv_color_hex(${color_7}); // red + } + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_dcl_derating_reason + id: ha_dcl_derating_reason + on_value: + then: + - lvgl.label.update: + id: lbl_dcl_derating_reason + text: !lambda 'return x;' + - lvgl.label.update: + id: lbl_dcl_derating + text: !lambda |- + if (x == "No Derating") { + return std::string("No Der."); + } else { + return std::string("Derating"); + } + text_color: !lambda |- + if (x == "No Derating") { + return lv_color_hex(${color_4}); // light blue + } else { + return lv_color_hex(${color_7}); // red + } + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_board_uptime + id: ha_board_uptime + on_value: + then: + - lvgl.label.update: + id: lbl_uptime + text: !lambda 'return x;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_board_esphome_version + id: ha_board_esphome_version + on_value: + then: + - lvgl.label.update: + id: lbl_esphome_ver + text: !lambda 'return x.substr(0, 8);' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_yambms_1_running_version + id: ha_running_version + on_value: + then: + - lvgl.label.update: + id: lbl_yambms_ver + text: !lambda 'return x;' + + - platform: homeassistant + entity_id: sensor.${entity_prefix}_system_fault_data + id: ha_sys_fault_data + on_value: + then: + - lambda: |- + // Parse JSON array: [[0],[0,0,0],[0],[],[0],[],[0],...] + // Index: 0=API/MQTT, 1=BMS, 2=CAN, 3=RS485, 4=Shunt, 5=Bal, 6=Net + + // Manual parsing since root is an array + if (x.empty() || x[0] != '[') { + ESP_LOGE("fault", "Invalid JSON format"); + return; + } + + // Helper to count faults in a device array + auto count_faults = [](const std::string& json_str, int dev_idx) -> std::pair { + // Returns {nok_count, total_count} + // Very simple parser - looks for [X,Y,Z] at device index + + int bracket_count = 0; + int current_dev = -1; + int nok = 0; + int total = 0; + bool in_array = false; + + for (size_t i = 0; i < json_str.length(); i++) { + if (json_str[i] == '[') { + bracket_count++; + if (bracket_count == 2) { + current_dev++; + in_array = true; + nok = 0; + total = 0; + } + } else if (json_str[i] == ']') { + bracket_count--; + if (bracket_count == 1 && in_array && current_dev == dev_idx) { + return {nok, total}; + } + in_array = false; + } else if (in_array && current_dev == dev_idx && (json_str[i] == '0' || json_str[i] == '1')) { + total++; + if (json_str[i] == '1') nok++; + } + } + + return {-1, 0}; // device not found or empty + }; + + // Helper to determine color based on status + auto get_status_color = [](int nok, int total) -> lv_color_t { + if (nok == -1 || total == 0) { + return lv_color_hex(${color_4}); // light blue = absent + } else if (nok > 0) { + return lv_color_hex(${color_7}); // red = NOK + } else { + return lv_color_hex(${color_5}); // green = OK + } + }; + + // Update single device status + auto update_device = [&](lv_obj_t* obj, int idx) { + auto [nok, total] = count_faults(x, idx); + lv_color_t color = get_status_color(nok, total); + lv_obj_set_style_bg_color(obj, color, 0); + }; + + // Update all fault status widgets + update_device(id(net_network), 6); // Network + update_device(id(net_api_mqtt), 0); // API/MQTT + update_device(id(net_can_inv), 2); // CAN->INV + update_device(id(net_rs485_inv), 3); // RS485->INV + update_device(id(bg_bms), 1); // BMS + update_device(id(bg_shunt), 4); // Shunt + update_device(id(bg_balancer), 5); // Balancer + +binary_sensor: + - platform: homeassistant + entity_id: binary_sensor.${entity_prefix}_yambms_1_equalizing_state + id: ha_equalizing_state + trigger_on_initial_state: true + on_state: + then: + - lvgl.label.update: + id: lbl_equalizing + text: !lambda 'return std::string("Equalizing: ") + (x ? "ON" : "OFF");' + text_color: !lambda 'return x ? lv_color_hex(${color_6}) : lv_color_hex(${color_2});' + + - platform: homeassistant + entity_id: binary_sensor.${entity_prefix}_yambms_1_discharging_instruction + id: ha_discharging_instruction + trigger_on_initial_state: true + on_state: + then: + - lvgl.label.update: + id: lbl_discharge_instr + text: !lambda 'return std::string(x ? "Allowed" : "Blocked");' + text_color: !lambda 'return x ? lv_color_hex(${color_4}) : lv_color_hex(${color_7});' + - lvgl.label.update: + id: lbl_dvl_instruction + text: !lambda 'return std::string(x ? "Allowed" : "Blocked");' + text_color: !lambda 'return x ? lv_color_hex(${color_4}) : lv_color_hex(${color_7});'