Files
esphome/templates/btproxy.yaml
T
artem 6f1dfedf2f Bump BT restart interval to 15min
To be on the safe side.

Also add logging for such restarts.
2025-01-25 14:01:30 +01:00

58 lines
1.3 KiB
YAML

# Remember to enable HA API (api.yaml) for the proxy to be available.
esp32:
# Required for BLE.
framework:
type: esp-idf
globals:
- id: ble_scans
type: int
restore_value: no
initial_value: '0'
esp32_ble_tracker:
scan_parameters:
# Recommended scan intervals for esphome.
interval: 1100ms
window: 1100ms
active: true
on_scan_end:
- then:
- sensor.template.publish:
id: ble_scans_finished
state: !lambda 'return ++id(ble_scans);'
- script.execute: restart_after_delay
bluetooth_proxy:
id: btproxy
active: true
script:
- id: restart_after_delay
mode: restart
then:
- delay: 15min
- logger.log:
level: ERROR
format: "No recent successful Bluetooth scan, restarting ESP chip"
- button.press: restart_button
sensor:
- platform: template
name: "btproxy connections free"
lambda: 'return id(btproxy).get_bluetooth_connections_free();'
update_interval: 60s
state_class: "measurement"
accuracy_decimals: 0
entity_category: diagnostic
icon: "mdi:bluetooth-settings"
- platform: template
name: "BLE scans finished"
id: ble_scans_finished
state_class: "total_increasing"
accuracy_decimals: 0
entity_category: diagnostic
icon: "mdi:bluetooth-settings"