Introducing "Add-on: Bluetooth Proxy"

Supports:
- #1983
- #1946
- #1815
This commit is contained in:
Edward Firmo
2024-04-18 18:34:49 +02:00
parent c9be4d2422
commit 544b2bc9cf
21 changed files with 198 additions and 113 deletions

View File

@@ -0,0 +1,43 @@
#####################################################################################################
##### NSPANEL ESPHOME created by Blackymas - https://github.com/Blackymas/NSPanel_HA_Blueprint #####
##### ESPHome Add-on for Bluetooth proxy #####
##### PLEASE only make changes if it is necessary and also the required knowledge is available. #####
##### For normal use with the Blueprint, no changes are necessary. #####
#####################################################################################################
##### ATTENTION: This will add climate elements to the core system and requires the core part. #####
#####################################################################################################
---
bluetooth_proxy:
id: ble_proxy
# Enable Bluetooth tracker
esp32_ble_tracker:
id: ble_tracker
esphome:
platformio_options:
build_flags:
- -D NSPANEL_HA_BLUEPRINT_ADDON_BLUETOOTH_PROXY
script:
- id: !extend dump_config
then:
- lambda: |-
// Check if this is installed with Arduino
#ifdef USE_ARDUINO
#error "Invalid settings for add-on Bluetooth Proxy. Arduino framework is not supported when using Bluetooth in this project."
#endif
if (!id(is_uploading_tft)) {
static const char *const TAG = "nspanel_ha_blueprint";
ESP_LOGCONFIG(TAG, "Add-on Bluetooth Proxy:");
ESP_LOGCONFIG(TAG, " Mode: %s", ble_proxy->has_active() ? "Active" : "Passive");
ESP_LOGCONFIG(TAG, " Connections: %i", int(ble_proxy->get_bluetooth_connections_limit() -
ble_proxy->get_bluetooth_connections_free()));
ESP_LOGCONFIG(TAG, " Limit: %i", int(ble_proxy->get_bluetooth_connections_limit()));
}
# Set Wi-Fi power save mode to "LIGHT" as required for Bluetooth on ESP32
wifi:
power_save_mode: LIGHT
...

View File

@@ -33,6 +33,7 @@ button:
- script.execute: exit_reparse
captive_portal:
id: ap_captive_portal
script:
- id: exit_reparse
@@ -76,9 +77,9 @@ sensor:
text_sensor:
##### ESPhome version used to compile the app #####
- name: ESPhome Version
- name: ESPhome Compiler
platform: version
disabled_by_default: false
disabled_by_default: true
internal: false
icon: mdi:tag-text-outline

View File

@@ -2274,6 +2274,9 @@ script:
#ifdef NSPANEL_HA_BLUEPRINT_ADVANCED
ESP_LOGCONFIG(TAG, " - Advanced");
#endif
#ifdef NSPANEL_HA_BLUEPRINT_ADDON_BLUETOOTH_PROXY
ESP_LOGCONFIG(TAG, " - Bluetooth Proxy");
#endif
#ifdef NSPANEL_HA_BLUEPRINT_ADDON_UPLOAD_TFT
ESP_LOGCONFIG(TAG, " - Upload TFT");
#endif
@@ -2296,10 +2299,7 @@ script:
ESP_LOGCONFIG(TAG, " - Pre-built (Wall Display)");
#endif
#if defined(USE_BLUETOOTH_PROXY) || defined(USE_WEBSERVER) || defined(USE_CAPTIVE_PORTAL)
ESP_LOGCONFIG(TAG, "Non-standard components:");
#ifdef USE_CAPTIVE_PORTAL
ESP_LOGCONFIG(TAG, " - Captive portal");
#endif
ESP_LOGCONFIG(TAG, "Components:");
#ifdef USE_ESP32_BLE_SERVER
ESP_LOGCONFIG(TAG, " - BLE server");
#endif
@@ -2309,6 +2309,9 @@ script:
#ifdef USE_BLUETOOTH_PROXY
ESP_LOGCONFIG(TAG, " - Bluetooth proxy");
#endif
#ifdef USE_CAPTIVE_PORTAL
ESP_LOGCONFIG(TAG, " - Captive portal");
#endif
#ifdef USE_IMPROV
ESP_LOGCONFIG(TAG, " - Improv (BLE)");
#endif
@@ -2533,6 +2536,9 @@ script:
disp1->set_component_font("home.wifi_icon", id(home_chip_font_id));
disp1->set_component_font_color("home.chip_relay1", id(home_relay1_icon_color));
disp1->set_component_font_color("home.chip_relay2", id(home_relay2_icon_color));
#if defined(USE_ESP32_BLE_SERVER) || defined(USE_ESP32_BLE_CLIENT) || defined(USE_BLUETOOTH_PROXY) || defined(USE_IMPROV)
disp1->set_component_text("home.bt_icon", "\uE0AE");
#endif
boot_progress->execute(8);
- wait_until:
condition: