# Plain ESPHome Bluetooth proxy — feeds Bermuda + HA's Private BLE Device (Phase 2,
# docs/project-plan.md §1.5). One of these per room, separate hardware from the
# RuView CSI-presence nodes (firmware/ruview/) — one radio chip, one job each,
# per §1.5's own "separate hardware from RuView nodes" note.
#
# This is a thin ESPHome config around a stock, first-party ESPHome component
# (`bluetooth_proxy`) — unlike firmware/ruview/, there is no custom signal-
# processing or hardware-specific bring-up here to get wrong; the only real
# per-unit decision is `room` below. See README.md before flashing.

substitutions:
  # REQUIRED per physical unit — every proxy needs a distinct hostname/name so HA
  # can tell them apart; Bermuda then uses ALL of them together (RSSI-triangulates
  # across whichever proxies see a given device) rather than picking just one.
  room: "living-room" # lowercase, hyphens only — becomes part of the hostname
  friendly_name: "BLE proxy (Living room)"

esphome:
  name: ble-proxy-${room}
  friendly_name: ${friendly_name}

# esp-idf (not Arduino) for the BLE proxy — VERIFY: current ESPHome versions have
# closed most of the gap between the two frameworks for esp32_ble_tracker/
# bluetooth_proxy, but esp-idf remains the framework ESPHome's own docs describe
# BLE proxy support against; check your ESPHome version's release notes if you'd
# rather use Arduino for a smaller/simpler build.
esp32:
  board: esp32dev # generic ESP32 dev board pinout — matches a Wemos D1 Mini32 or
                   # similar per docs/project-plan.md §1.5's "D1 Mini32 or similar"
                   # hardware pick. If your specific board has a distinct ESPHome
                   # board id (check https://esphome.io/components/esp32.html),
                   # use that instead — esp32dev is the safe generic fallback.
  framework:
    type: esp-idf

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "${friendly_name} Fallback"
    password: !secret ap_password

captive_portal:

logger:
  level: WARN # esp32_ble_tracker is chatty at INFO — see README.md if debugging

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    password: !secret ota_password

# --- The actual point of this device -----------------------------------------
esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

bluetooth_proxy:
  active: true # active-mode (not just passive) — required for Private BLE Device
                # to resolve rotating IRK-based MACs, not just report raw adverts

# Nice-to-haves that cost nothing extra and make "is this proxy alive" a one-glance
# check from HA, same reasoning as thinclient-agent's own MQTT sensors elsewhere
# in this project — not load-bearing for presence itself.
sensor:
  - platform: wifi_signal
    name: "${friendly_name} WiFi signal"
    update_interval: 60s

button:
  - platform: restart
    name: "${friendly_name} restart"
