From 34b097588580043dd80129502c27dd3496003550 Mon Sep 17 00:00:00 2001 From: Heinz <> Date: Fri, 19 Jan 2024 09:45:38 +0200 Subject: [PATCH 1/3] shutdown bluetooth during ota flashing --- esp32-ble-example-multiple-devices.yaml | 8 ++++++++ esp32-ble-example.yaml | 8 +++++++- esp32-ble-jk04-example.yaml | 8 +++++++- esp32-ble-uart-hybrid-example.yaml | 8 +++++++- esp32-ble-v11-example.yaml | 6 ++++++ yaml-snippets/esp32-ble-block-traffic.yaml | 7 +++++++ yaml-snippets/esp32-ble-energy-dashboard.yaml | 8 +++++++- 7 files changed, 49 insertions(+), 4 deletions(-) diff --git a/esp32-ble-example-multiple-devices.yaml b/esp32-ble-example-multiple-devices.yaml index 3de3f8da..c75c4817 100644 --- a/esp32-ble-example-multiple-devices.yaml +++ b/esp32-ble-example-multiple-devices.yaml @@ -33,6 +33,12 @@ wifi: password: !secret wifi_password ota: + on_begin: + then: + - lambda: |- + id(bluetooth_client0_enabled_switch).turn_off(); + id(bluetooth_client1_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" logger: level: DEBUG @@ -189,9 +195,11 @@ switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_client0_enabled_switch name: "${bms0} enable bluetooth connection" - platform: ble_client ble_client_id: client1 + id: bluetooth_client1_enabled_switch name: "${bms1} enable bluetooth connection" text_sensor: diff --git a/esp32-ble-example.yaml b/esp32-ble-example.yaml index 0f8b1c49..82fb03c8 100644 --- a/esp32-ble-example.yaml +++ b/esp32-ble-example.yaml @@ -29,7 +29,12 @@ wifi: password: !secret wifi_password ota: - + on_begin: + then: + - lambda: |- + id(bluetooth_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" + logger: level: DEBUG @@ -271,6 +276,7 @@ switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_enabled_switch name: "${name} enable bluetooth connection" text_sensor: diff --git a/esp32-ble-jk04-example.yaml b/esp32-ble-jk04-example.yaml index 11e1a49c..60f9076d 100644 --- a/esp32-ble-jk04-example.yaml +++ b/esp32-ble-jk04-example.yaml @@ -29,7 +29,12 @@ wifi: password: !secret wifi_password ota: - + on_begin: + then: + - lambda: |- + id(bluetooth_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" + logger: level: DEBUG @@ -207,4 +212,5 @@ switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_enabled_switch name: "${name} enable bluetooth connection" diff --git a/esp32-ble-uart-hybrid-example.yaml b/esp32-ble-uart-hybrid-example.yaml index 6a9af523..087725e8 100644 --- a/esp32-ble-uart-hybrid-example.yaml +++ b/esp32-ble-uart-hybrid-example.yaml @@ -35,7 +35,12 @@ wifi: password: !secret wifi_password ota: - + on_begin: + then: + - lambda: |- + id(bluetooth_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" + logger: level: DEBUG @@ -210,6 +215,7 @@ switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_enabled_switch name: "${name} enable bluetooth connection" text_sensor: diff --git a/esp32-ble-v11-example.yaml b/esp32-ble-v11-example.yaml index 222e8db9..40580cb0 100644 --- a/esp32-ble-v11-example.yaml +++ b/esp32-ble-v11-example.yaml @@ -29,6 +29,11 @@ wifi: password: !secret wifi_password ota: + on_begin: + then: + - lambda: |- + id(bluetooth_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" logger: level: DEBUG @@ -277,6 +282,7 @@ switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_enabled_switch name: "${name} enable bluetooth connection" text_sensor: diff --git a/yaml-snippets/esp32-ble-block-traffic.yaml b/yaml-snippets/esp32-ble-block-traffic.yaml index 953e2e25..ab46c467 100644 --- a/yaml-snippets/esp32-ble-block-traffic.yaml +++ b/yaml-snippets/esp32-ble-block-traffic.yaml @@ -20,6 +20,12 @@ wifi: password: !secret wifi_password ota: + on_begin: + then: + - lambda: |- + id(bluetooth_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" + logger: # If you don't use Home Assistant please remove this `api` section and uncomment the `mqtt` component! @@ -43,4 +49,5 @@ ble_client: switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_enabled_switch name: "${name} enable bluetooth connection" diff --git a/yaml-snippets/esp32-ble-energy-dashboard.yaml b/yaml-snippets/esp32-ble-energy-dashboard.yaml index 807a310d..d6f7f00f 100644 --- a/yaml-snippets/esp32-ble-energy-dashboard.yaml +++ b/yaml-snippets/esp32-ble-energy-dashboard.yaml @@ -27,7 +27,12 @@ wifi: password: !secret wifi_password ota: - + on_begin: + then: + - lambda: |- + id(bluetooth_enabled_switch).turn_off(); + - logger.log: "BLE shutdown for flashing" + logger: level: DEBUG @@ -94,4 +99,5 @@ sensor: switch: - platform: ble_client ble_client_id: client0 + id: bluetooth_enabled_switch name: "${name} enable bluetooth connection" From 8f6edd0a40223e51731e6aa12c14757542ea0e6a Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 20 Jan 2024 10:01:33 +0100 Subject: [PATCH 2/3] Simplify --- esp32-ble-example-multiple-devices.yaml | 11 +++++------ esp32-ble-example.yaml | 9 ++++----- esp32-ble-jk04-example.yaml | 9 ++++----- esp32-ble-uart-hybrid-example.yaml | 9 ++++----- esp32-ble-v11-example.yaml | 7 +++---- yaml-snippets/esp32-ble-block-traffic.yaml | 9 ++++----- yaml-snippets/esp32-ble-energy-dashboard.yaml | 9 ++++----- 7 files changed, 28 insertions(+), 35 deletions(-) diff --git a/esp32-ble-example-multiple-devices.yaml b/esp32-ble-example-multiple-devices.yaml index c75c4817..89dec83c 100644 --- a/esp32-ble-example-multiple-devices.yaml +++ b/esp32-ble-example-multiple-devices.yaml @@ -35,10 +35,9 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_client0_enabled_switch).turn_off(); - id(bluetooth_client1_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" + - switch.turn_off: ble_client_switch0 + - switch.turn_off: ble_client_switch1 + - logger.log: "BLE connection suspended for OTA update" logger: level: DEBUG @@ -195,11 +194,11 @@ switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_client0_enabled_switch + id: ble_client_switch0 name: "${bms0} enable bluetooth connection" - platform: ble_client ble_client_id: client1 - id: bluetooth_client1_enabled_switch + id: ble_client_switch1 name: "${bms1} enable bluetooth connection" text_sensor: diff --git a/esp32-ble-example.yaml b/esp32-ble-example.yaml index 82fb03c8..2f4ec7e1 100644 --- a/esp32-ble-example.yaml +++ b/esp32-ble-example.yaml @@ -31,10 +31,9 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" - + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" + logger: level: DEBUG @@ -276,7 +275,7 @@ switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_enabled_switch + id: ble_client_switch0 name: "${name} enable bluetooth connection" text_sensor: diff --git a/esp32-ble-jk04-example.yaml b/esp32-ble-jk04-example.yaml index 60f9076d..bd23ccc8 100644 --- a/esp32-ble-jk04-example.yaml +++ b/esp32-ble-jk04-example.yaml @@ -31,10 +31,9 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" - + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" + logger: level: DEBUG @@ -212,5 +211,5 @@ switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_enabled_switch + id: ble_client_switch0 name: "${name} enable bluetooth connection" diff --git a/esp32-ble-uart-hybrid-example.yaml b/esp32-ble-uart-hybrid-example.yaml index 087725e8..03418340 100644 --- a/esp32-ble-uart-hybrid-example.yaml +++ b/esp32-ble-uart-hybrid-example.yaml @@ -37,10 +37,9 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" - + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" + logger: level: DEBUG @@ -215,7 +214,7 @@ switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_enabled_switch + id: ble_client_switch0 name: "${name} enable bluetooth connection" text_sensor: diff --git a/esp32-ble-v11-example.yaml b/esp32-ble-v11-example.yaml index 40580cb0..6887c670 100644 --- a/esp32-ble-v11-example.yaml +++ b/esp32-ble-v11-example.yaml @@ -31,9 +31,8 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" logger: level: DEBUG @@ -282,7 +281,7 @@ switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_enabled_switch + id: ble_client_switch0 name: "${name} enable bluetooth connection" text_sensor: diff --git a/yaml-snippets/esp32-ble-block-traffic.yaml b/yaml-snippets/esp32-ble-block-traffic.yaml index ab46c467..25806f6d 100644 --- a/yaml-snippets/esp32-ble-block-traffic.yaml +++ b/yaml-snippets/esp32-ble-block-traffic.yaml @@ -22,10 +22,9 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" - + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" + logger: # If you don't use Home Assistant please remove this `api` section and uncomment the `mqtt` component! @@ -49,5 +48,5 @@ ble_client: switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_enabled_switch + id: ble_client_switch0 name: "${name} enable bluetooth connection" diff --git a/yaml-snippets/esp32-ble-energy-dashboard.yaml b/yaml-snippets/esp32-ble-energy-dashboard.yaml index d6f7f00f..c8d89664 100644 --- a/yaml-snippets/esp32-ble-energy-dashboard.yaml +++ b/yaml-snippets/esp32-ble-energy-dashboard.yaml @@ -29,10 +29,9 @@ wifi: ota: on_begin: then: - - lambda: |- - id(bluetooth_enabled_switch).turn_off(); - - logger.log: "BLE shutdown for flashing" - + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" + logger: level: DEBUG @@ -99,5 +98,5 @@ sensor: switch: - platform: ble_client ble_client_id: client0 - id: bluetooth_enabled_switch + id: ble_client_switch0 name: "${name} enable bluetooth connection" From e4cce612139081f1d21430b8c30620136ebe4b5b Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sat, 20 Jan 2024 10:06:30 +0100 Subject: [PATCH 3/3] Extend Heltec Balancer example --- esp32-heltec-balancer-ble-example.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/esp32-heltec-balancer-ble-example.yaml b/esp32-heltec-balancer-ble-example.yaml index 400a16bd..9d1dbd77 100644 --- a/esp32-heltec-balancer-ble-example.yaml +++ b/esp32-heltec-balancer-ble-example.yaml @@ -25,6 +25,10 @@ wifi: password: !secret wifi_password ota: + on_begin: + then: + - switch.turn_off: ble_client_switch0 + - logger.log: "BLE connection suspended for OTA update" logger: level: DEBUG @@ -232,6 +236,11 @@ switch: balancer: name: "${name} balancer" + - platform: ble_client + ble_client_id: client0 + id: ble_client_switch0 + name: "${name} enable bluetooth connection" + text_sensor: - platform: heltec_balancer_ble # Not implemented