setting up esphome

This commit is contained in:
2025-10-31 18:00:55 -04:00
parent 9416bbd00b
commit ef25153c84
6 changed files with 238 additions and 0 deletions

View File

@@ -149,10 +149,12 @@
"mklabel", "mklabel",
"mkpart", "mkpart",
"modbus", "modbus",
"modbuss",
"modesetting", "modesetting",
"mountpoint", "mountpoint",
"mountpoints", "mountpoints",
"mousewheel", "mousewheel",
"mqtt",
"mtxr", "mtxr",
"ncdu", "ncdu",
"nemo", "nemo",

3
esphome/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# esphome
/.esphome/
/secrets.yaml

129
esphome/batteries.yml Normal file
View File

@@ -0,0 +1,129 @@
esphome:
name: batteries
friendly_name: batteries
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
encryption:
key: !secret api_key
external_components:
- source: github://syssi/esphome-jk-bms@main
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
ble_client:
- mac_address: "C8:47:80:29:0F:DB"
id: jk_ble0
- mac_address: "C8:47:80:37:9D:DD"
id: jk_ble1
jk_bms_ble:
- ble_client_id: jk_ble0
protocol_version: JK02_32S
throttle: 1s
id: jk_bms0
- ble_client_id: jk_ble1
protocol_version: JK02_32S
throttle: 1s
id: jk_bms1
sensor:
# BMS1 sensors
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
total_voltage:
name: "JK0 Total Voltage"
current:
name: "JK0 Current"
state_of_charge:
name: "JK0 SoC"
power:
name: "JK0 Power"
temperature_sensor_1:
name: "JK0 Temp 1"
temperature_sensor_2:
name: "JK0 Temp 2"
balancing:
name: "JK0 balancing"
charging_cycles:
name: "JK0 charging cycles"
total_runtime:
name: "JK0 total runtime"
balancing_current:
name: "JK0 balancing current"
# BMS2 sensors
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
total_voltage:
name: "JK1 Total Voltage"
current:
name: "JK1 Current"
state_of_charge:
name: "JK1 SoC"
power:
name: "Jk1 Power"
temperature_sensor_1:
name: "JK1 Temp 1"
temperature_sensor_2:
name: "Jk1 Temp 2"
balancing:
name: "JK1 balancing"
charging_cycles:
name: "JK1 charging cycles"
total_runtime:
name: "JK1 total runtime"
balancing_current:
name: "JK1 balancing current"
text_sensor:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
errors:
name: "JK0 Errors"
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
errors:
name: "JK1 Errors"
switch:
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms0
charging:
name: "JK0 Charging"
discharging:
name: "JK0 Discharging"
balancer:
name: "JK0 Balancing"
- platform: jk_bms_ble
jk_bms_ble_id: jk_bms1
charging:
name: "JK1 Charging"
discharging:
name: "JK1 Discharging"
balancer:
name: "JK1 Balancing"

View File

@@ -28,6 +28,7 @@
temperature_unit = "F"; temperature_unit = "F";
packages = { packages = {
victron_modbuss = "!include ${./home_assistant/victron_modbuss.yaml}"; victron_modbuss = "!include ${./home_assistant/victron_modbuss.yaml}";
battery_sensors = "!include ${./home_assistant/battery_sensors.yaml}";
}; };
}; };
recorder = { recorder = {
@@ -67,6 +68,8 @@
forecast-solar # for solar forecast forecast-solar # for solar forecast
aioesphomeapi # for esphome aioesphomeapi # for esphome
esphome-dashboard-api # for esphome esphome-dashboard-api # for esphome
py-improv-ble-client # for esphome
bleak-esphome # for esphome
]; ];
extraComponents = [ "isal" ]; extraComponents = [ "isal" ];
}; };

View File

@@ -0,0 +1,99 @@
template:
- sensor:
# Battery 0
- name: "JK0 charge power W"
unique_id: jk0_charge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk0_power')|float(0) %}
{{ max(0, p) }}
- name: "JK0 discharge power W"
unique_id: jk0_discharge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk0_power')|float(0) %}
{{ max(0, -p) }}
# Battery 1
- name: "JK1 charge power W"
unique_id: jk1_charge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk1_power')|float(0) %}
{{ max(0, p) }}
- name: "JK1 discharge power W"
unique_id: jk1_discharge_power_w
unit_of_measurement: W
device_class: power
state_class: measurement
state: >
{% set p = states('sensor.batteries_jk1_power')|float(0) %}
{{ max(0, -p) }}
sensor:
# Battery 0
- platform: integration
source: sensor.jk0_charge_power_w
name: "JK0 energy in"
unique_id: jk0_energy_in_kwh
unit_prefix: k
method: trapezoidal
round: 3
max_sub_interval:
minutes: 5
- platform: integration
source: sensor.jk0_discharge_power_w
name: "JK0 energy out"
unique_id: jk0_energy_out_kwh
unit_prefix: k
method: trapezoidal
round: 3
max_sub_interval:
minutes: 5
# Battery 1
- platform: integration
source: sensor.jk1_charge_power_w
name: "JK1 energy in"
unique_id: jk1_energy_in_kwh
unit_prefix: k
method: trapezoidal
round: 3
max_sub_interval:
minutes: 5
- platform: integration
source: sensor.jk1_discharge_power_w
name: "JK1 energy out"
unique_id: jk1_energy_out_kwh
unit_prefix: k
method: trapezoidal
round: 3
max_sub_interval:
minutes: 5
utility_meter:
# Battery 0
jk0_energy_in_daily:
source: sensor.jk0_energy_in
name: "JK0 Energy In Daily"
cycle: daily
jk0_energy_out_daily:
source: sensor.jk0_energy_out
name: "JK0 Energy Out Daily"
cycle: daily
# Battery 1
jk1_energy_in_daily:
source: sensor.jk1_energy_in
name: "JK1 Energy In Daily"
cycle: daily
jk1_energy_out_daily:
source: sensor.jk1_energy_out
name: "JK1 Energy Out Daily"
cycle: daily

View File

@@ -24,6 +24,8 @@
unzip unzip
yazi yazi
zoxide zoxide
# Home Assistant
esphome
# data recovery # data recovery
testdisk testdisk
# system info # system info