Skip to content

Commit

Permalink
Use the BLE scanner to identify the MAC address of your BMS (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Oct 19, 2024
1 parent 0ef61ba commit 6317140
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 109 deletions.
12 changes: 0 additions & 12 deletions esp32-ble-example-multiple-devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${bms0_mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-ble-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-ble-jk04-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${mac_address}
Expand Down
2 changes: 1 addition & 1 deletion esp32-ble-scanner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ api:

esp32_ble_tracker:
scan_parameters:
active: false
active: true
on_ble_advertise:
then:
- lambda: |-
Expand Down
12 changes: 0 additions & 12 deletions esp32-ble-uart-hybrid-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ mqtt:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-ble-v11-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-ble-v14-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-ble-v14-multiple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("JK-", 0) == 0 || x.get_name().rfind("JK_", 0) == 0) {
ESP_LOGI("ble_adv", "New JK-BMS found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${bms0_mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-heltec-balancer-ble-example-multiple-devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("GW-", 0) == 0) {
ESP_LOGI("ble_adv", "New Heltec/NEEY balancer found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${balancer0_mac_address}
Expand Down
12 changes: 0 additions & 12 deletions esp32-heltec-balancer-ble-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ api:
esp32_ble_tracker:
scan_parameters:
active: false
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("GW-", 0) == 0) {
ESP_LOGI("ble_adv", "New Heltec/NEEY balancer found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}

ble_client:
- mac_address: ${mac_address}
Expand Down
51 changes: 51 additions & 0 deletions esp32-heltec-balancer-ble-scanner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
substitutions:
name: ble-scanner
device_description: "Search for BLE devices"

esphome:
name: ${name}
comment: ${device_description}
min_version: 2024.6.0
project:
name: "syssi.esphome-jk-bms"
version: 2.1.0

esp32:
board: wemos_d1_mini32
framework:
type: esp-idf

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

ota:
platform: esphome

logger:
level: DEBUG
logs:
wifi: WARN

api:
reboot_timeout: 0s

esp32_ble_tracker:
scan_parameters:
active: true
on_ble_advertise:
then:
- lambda: |-
if (x.get_name().rfind("GW-", 0) == 0) {
ESP_LOGI("ble_adv", "New Heltec/NEEY balancer found");
ESP_LOGI("ble_adv", " Name: %s", x.get_name().c_str());
ESP_LOGI("ble_adv", " MAC address: %s", x.address_str().c_str());
ESP_LOGD("ble_adv", " Advertised service UUIDs:");
for (auto uuid : x.get_service_uuids()) {
ESP_LOGD("ble_adv", " - %s", uuid.to_string().c_str());
}
}
text_sensor:
- platform: ble_scanner
name: "BLE Devices Scanner"

0 comments on commit 6317140

Please sign in to comment.