external_components:
  - source:
      type: local
      path: components

mqtt:
  broker: !secret mqtt_broker
  username: !secret mqtt_username
  password: !secret mqtt_password
  discovery: false
  id: mqtt_client

globals:
  - id: room_topic
    type: std::string
    initial_value: '"room_presence/${room_name}"'

nimble_tracker:
  scan_parameters:
    # window: 500ms
    # interval: 1.2s

    window: 100ms
    interval: 100ms
    active: false

sensor:
  - platform: nimble_distance
    name: "Часы"
    mac: "dc:d3:24:8e:a0:05"
    id: maxim_watch_distance
    on_value:
      then:
        - lambda: |-
            id(mqtt_client)->publish_json(id(room_topic), [=](ArduinoJson::JsonObject root) -> void {
              root["id"] = "maxim_watch";
              root["name"] = "Maxim Watch";
              root["distance"] = id(maxim_watch_distance).state;
            });            

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_FREERTOS_UNICORE: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_160: y
      CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ: "160"
      # From https://github.com/esphome/issues/issues/2941
      # Increase watchdog timeout to flash firmware with bluetooth enabled, fixes error:
      # ERROR Error receiving acknowledge binary size: timed out
      CONFIG_ESP_TASK_WDT_TIMEOUT_S: "20"
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
    

# Enable logging
logger:
#  level: VERY_VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: "gZVa2Smtq23LxQudEPzXAmnHu4CkjuOkhZQTwgbJXl4="

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-Dc7854"
    password: "zBeoh1DTmc9m"

captive_portal: