BERIKUT TAMPILAN WEB LOKALNYA
BERIKUT KODENYA
esphome:
name: dara-tes-esp
min_version: 2025.9.1
build_path: build/dara-tes-esp
on_boot:
priority: -10
then:
- script.execute: apply_hysteresis
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
api:
ota:
- platform: esphome
wifi:
ssid: "Dara@Home"
password: "rejeki88"
manual_ip:
static_ip: 192.188.1.236
gateway: 192.188.1.1
subnet: 255.255.255.0
ap:
ssid: "ESP Fallback"
password: "fallback1234"
web_server:
port: 80
captive_portal:
# Komponen JK-BMS langsung dari GitHub (paling baru)
external_components:
- source: github://syssi/esphome-jk-bms@main
refresh: 0s
esp32_ble_tracker:
scan_parameters:
active: false
# GANTI MAC di sini
ble_client:
- mac_address: "C8:47:80:25:45:CF"
id: client0
# Protokol JK untuk HW baru
jk_bms_ble:
- ble_client_id: client0
protocol_version: JK02_32S
throttle: 8s
id: bms0
# --- I2C / OLED ---
i2c:
sda: GPIO21
scl: GPIO22
scan: true
font:
- id: font_14
file: "gfonts://Roboto"
size: 14
# =========================
# SENSORS
# =========================
sensor:
- platform: jk_bms_ble
jk_bms_ble_id: bms0
total_voltage:
name: "JK Total Voltage"
id: jk_total_voltage
capacity_remaining:
name: "JK SOC"
id: jk_soc
min_cell_voltage:
name: "JK Min Cell V"
max_cell_voltage:
name: "JK Max Cell V"
min_voltage_cell:
name: "JK Min Voltage Cell #"
max_voltage_cell:
name: "JK Max Voltage Cell #"
average_cell_voltage:
name: "JK Avg Cell V"
delta_cell_voltage:
name: "JK Delta Cell V"
cell_voltage_1:
name: "JK Cell V1"
cell_voltage_2:
name: "JK Cell V2"
cell_voltage_3:
name: "JK Cell V3"
cell_voltage_4:
name: "JK Cell V4"
cell_voltage_5:
name: "JK Cell V5"
cell_voltage_6:
name: "JK Cell V6"
cell_voltage_7:
name: "JK Cell V7"
cell_voltage_8:
name: "JK Cell V8"
cell_voltage_9:
name: "JK Cell V9"
cell_voltage_10:
name: "JK Cell V10"
cell_voltage_11:
name: "JK Cell V11"
cell_voltage_12:
name: "JK Cell V12"
cell_voltage_13:
name: "JK Cell V13"
cell_voltage_14:
name: "JK Cell V14"
cell_voltage_15:
name: "JK Cell V15"
# =========================
# Kontrol -> GPIO32 & GPIO33 (independen)
# =========================
output:
- platform: gpio
pin: GPIO32
id: out_gpio32
- platform: gpio
pin: GPIO33
id: out_gpio33
switch:
# Output fisik
- platform: output
name: "SOC Output GPIO32"
id: soc_output_32
output: out_gpio32
restore_mode: RESTORE_DEFAULT_OFF
- platform: output
name: "SOC Output GPIO33"
id: soc_output_33
output: out_gpio33
restore_mode: RESTORE_DEFAULT_OFF
# Toggle Auto Control per pin (pakai restore_mode)
- platform: template
name: "Auto Control by SOC (GPIO32)"
id: auto_soc_enable_32
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action: []
turn_off_action: []
- platform: template
name: "Auto Control by SOC (GPIO33)"
id: auto_soc_enable_33
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
turn_on_action: []
turn_off_action: []
number:
# Ambang untuk GPIO32
- platform: template
name: "SOC Ah Min (ON) - GPIO32"
id: soc_ah_min_on_32
unit_of_measurement: "Ah"
min_value: 0
max_value: 100
step: 0.1
optimistic: true
restore_value: true
initial_value: 19.9
- platform: template
name: "SOC Ah Max (OFF) - GPIO32"
id: soc_ah_max_off_32
unit_of_measurement: "Ah"
min_value: 0
max_value: 100
step: 0.1
optimistic: true
restore_value: true
initial_value: 25.5
# Ambang untuk GPIO33
- platform: template
name: "SOC Ah Min (ON) - GPIO33"
id: soc_ah_min_on_33
unit_of_measurement: "Ah"
min_value: 0
max_value: 100
step: 0.1
optimistic: true
restore_value: true
initial_value: 19.2
- platform: template
name: "SOC Ah Max (OFF) - GPIO33"
id: soc_ah_max_off_33
unit_of_measurement: "Ah"
min_value: 0
max_value: 100
step: 0.1
optimistic: true
restore_value: true
initial_value: 25.5
# Script berisi logika histeresis (dipanggil di boot dan tiap interval)
script:
- id: apply_hysteresis
mode: queued
then:
# Kontrol untuk GPIO32
- if:
condition:
lambda: |-
return id(auto_soc_enable_32).state &&
(id(jk_soc).state <= id(soc_ah_min_on_32).state);
then:
- switch.turn_on: soc_output_32
- if:
condition:
lambda: |-
return id(auto_soc_enable_32).state &&
(id(jk_soc).state >= id(soc_ah_max_off_32).state);
then:
- switch.turn_off: soc_output_32
# Kontrol untuk GPIO33
- if:
condition:
lambda: |-
return id(auto_soc_enable_33).state &&
(id(jk_soc).state <= id(soc_ah_min_on_33).state);
then:
- switch.turn_on: soc_output_33
- if:
condition:
lambda: |-
return id(auto_soc_enable_33).state &&
(id(jk_soc).state >= id(soc_ah_max_off_33).state);
then:
- switch.turn_off: soc_output_33
# Evaluasi berkala
interval:
- interval: 5s
then:
- script.execute: apply_hysteresis
# --- OLED 0.96" ---
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
update_interval: 5s
lambda: |-
it.clear();
it.printf(0, 0, id(font_14), "Hello World");
if (id(jk_total_voltage).has_state()) it.printf(0, 32, id(font_14), "V: %.2fV", id(jk_total_voltage).state);
if (id(jk_soc).has_state()) it.printf(80, 32, id(font_14), "SOC: %.2f Ah", id(jk_soc).state);
Comments
Post a Comment