From e5c7d8ce5cefd2447511a8166103cf310f321566 Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Sat, 7 Dec 2024 11:39:59 +0100 Subject: [PATCH] Enable encryption for HA API calls Also extract configs from btproxy into API and btproxy for reuse later. --- btproxy.yaml | 24 +++--------------------- templates/api.yaml | 7 +++++++ templates/btproxy.yaml | 16 ++++++++++++++++ templates/secrets.yaml.sample | 1 + 4 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 templates/api.yaml create mode 100644 templates/btproxy.yaml diff --git a/btproxy.yaml b/btproxy.yaml index 5edbe51..41b20be 100644 --- a/btproxy.yaml +++ b/btproxy.yaml @@ -6,27 +6,9 @@ esphome: name: dasfoo.btproxy version: "1.0" -esp32: - # Required for BLE. - framework: - type: esp-idf - packages: device_base: !include templates/esp32-poe.yaml -# Allow HA to use our proxy. -api: - -# Disable MQTT discovery to prevent duplicate device. -mqtt: - discovery: false - -esp32_ble_tracker: - scan_parameters: - # Recommended scan intervals for esphome. - interval: 1100ms - window: 1100ms - active: true - -bluetooth_proxy: - active: true + btproxy: !include templates/btproxy.yaml + # Allow HA to use our proxy. + api: !include templates/api.yaml diff --git a/templates/api.yaml b/templates/api.yaml new file mode 100644 index 0000000..c67fc8b --- /dev/null +++ b/templates/api.yaml @@ -0,0 +1,7 @@ +api: + encryption: + key: !secret api_encryption_key + +# Disable MQTT discovery to prevent duplicate device. +mqtt: + discovery: false diff --git a/templates/btproxy.yaml b/templates/btproxy.yaml new file mode 100644 index 0000000..0c2f419 --- /dev/null +++ b/templates/btproxy.yaml @@ -0,0 +1,16 @@ +# Remember to enable HA API (api.yaml) for the proxy to be available. + +esp32: + # Required for BLE. + framework: + type: esp-idf + +esp32_ble_tracker: + scan_parameters: + # Recommended scan intervals for esphome. + interval: 1100ms + window: 1100ms + active: true + +bluetooth_proxy: + active: true diff --git a/templates/secrets.yaml.sample b/templates/secrets.yaml.sample index d9ec3fe..81e8e53 100644 --- a/templates/secrets.yaml.sample +++ b/templates/secrets.yaml.sample @@ -5,3 +5,4 @@ mqtt_password: "ttqm" lock_pin: 314 wifi_ap_lookup: - "12:34:56:AB:CD -> Upper Floor AP" +api_encryption_key: "K3g+SB5OYgLxKtEXhWJd1Mryfy9hGol+mAq+nq/JDsY="