esphome/config.yaml

111 lines
2.6 KiB
YAML
Raw Permalink Normal View History

2023-12-02 12:01:23 +03:00
substitutions:
device_name: "nimble-shelly"
entity_id: "nimble_shelly"
room_name: "office"
mqtt:
broker: !secret mqtt_broker
username: esphome
password: !secret mqtt_password
discovery: false
id: mqtt_client
external_components:
- source:
type: local
path: ./components
nimble_tracker:
scan_parameters:
# window: 500ms
# interval: 1.2s
window: 100ms
interval: 100ms
active: false
globals:
- id: room_topic
type: std::string
initial_value: '"room_presence/${room_name}"'
sensor:
- platform: nimble_distance
irk: !secret apple_watch_irk
name: "Apple Watch Distance"
id: apple_watch_distance
internal: true
# TODO: should we retain the mqtt message?
on_value:
then:
- lambda: |-
id(mqtt_client)->publish_json(id(room_topic), [=](ArduinoJson::JsonObject root) -> void {
root["id"] = "apple_watch";
root["name"] = "Apple Watch";
root["distance"] = id(apple_watch_distance).state;
});
esphome:
name: ${device_name}
platformio_options:
board_build.f_cpu: 160000000L
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
output:
- platform: gpio
id: "relay_output"
pin: GPIO26
status_led:
pin:
number: GPIO0
inverted: true
# Enable logging
logger:
level: VERBOSE
# Enable Home Assistant API
api:
encryption:
key: !secret api_encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
password: !secret wifi_password
switch:
- platform: output
id: shelly_relay
name: "${entity_id}"
output: "relay_output"
# after reboot, keep the relay off. this prevents light turning on after a power outage
restore_mode: ALWAYS_OFF
# From https://community.home-assistant.io/t/shelly-plus-1-esphome-bletracker/363549/38
# Setup a button in home assistant to reboot the shelly into safe mode
button:
- platform: safe_mode
name: "${entity_id}_safe_mode_restart"