Files
esp32-configs/athom-garage-door.yaml
T
2025-08-19 17:07:02 +08:00

243 lines
6.0 KiB
YAML

substitutions:
# Default name
name: "athom-garage-door"
# Default friendly name
friendly_name: "Athom Garage Door"
# Allows ESP device to be automatically linked to an 'Area' in Home Assistant. Typically used for areas such as 'Lounge Room', 'Kitchen' etc
room: ""
# Description as appears in ESPHome & top of webserver page
device_description: "athom esp32-c3 garage door opener"
# Project Name
project_name: "Athom Technology.Garage Door Opener"
# Project version denotes the release version of the yaml file, allowing checking of deployed vs latest version
project_version: "v3.0.1"
# Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
dns_domain: ".local"
# Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
timezone: ""
# Set the duration between the sntp service polling ntp.org servers for an update
sntp_update_interval: 6h
# Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
sntp_server_1: "0.pool.ntp.org"
sntp_server_2: "1.pool.ntp.org"
sntp_server_3: "2.pool.ntp.org"
# Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
wifi_fast_connect: "false"
# Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
log_level: "DEBUG"
# Enable or disable the use of IPv6 networking on the device
ipv6_enable: "false"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
comment: "${device_description}"
area: "${room}"
name_add_mac_suffix: true
min_version: 2025.7.0
project:
name: "${project_name}"
version: "${project_version}"
platformio_options:
board_build.mcu: esp32c3
board_build.variant: esp32c3
board_build.flash_mode: dio
esp32:
board: esp32-c3-devkitm-1
flash_size: 4MB
variant: ESP32C3
framework:
type: esp-idf
version: recommended
api:
ota:
- platform: esphome
logger:
baud_rate: 115200
level: ${log_level}
hardware_uart: UART0
mdns:
disabled: false
web_server:
port: 80
network:
enable_ipv6: ${ipv6_enable}
wifi:
ap: {}
fast_connect: "${wifi_fast_connect}"
domain: "${dns_domain}"
captive_portal:
improv_serial:
esp32_improv:
authorizer: none
dashboard_import:
package_import_url: github://athom-tech/esp32-configs/athom-garage-door.yaml
sensor:
- platform: uptime
name: "Uptime Sensor"
id: uptime_sensor
type:
timestamp
entity_category: "diagnostic"
- platform: wifi_signal
name: "WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
- platform: copy
source_id: wifi_signal_db
name: "WiFi Signal Percent"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
device_class: ""
binary_sensor:
- platform: status
name: "Status"
- platform: gpio
name: "Contact"
disabled_by_default: true
device_class: garage_door
id: contact
pin:
number: GPIO18
inverted: true
filters:
- delayed_on: 20ms
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "Button"
disabled_by_default: true
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at least 0.2s
then:
- switch.turn_on: relay
- timing:
- ON for at least 4s
then:
- button.press: Reset
button:
- platform: restart
name: "Restart"
entity_category: config
- platform: factory_reset
name: "Factory Reset"
id: Reset
entity_category: config
- platform: safe_mode
name: "Safe Mode"
internal: false
entity_category: config
switch:
- platform: gpio
pin: GPIO7
name: "Relay"
id: relay
disabled_by_default: true
on_turn_on:
- light.turn_on: wifi_led
- delay: 1s
- switch.turn_off: relay
- light.turn_off: wifi_led
light:
- platform: status_led
name: "Status LED"
id: wifi_led
disabled_by_default: true
pin: GPIO4
cover:
- platform: template
device_class: garage
name: "Garage Door"
lambda: "return id(contact).state ? COVER_OPEN : COVER_CLOSED;"
open_action:
then:
- if:
condition:
lambda: 'return !id(contact).state;'
then:
- switch.turn_on: relay
stop_action:
- switch.turn_on: relay
close_action:
then:
- if:
condition:
lambda: 'return id(contact).state;'
then:
- switch.turn_on: relay
text_sensor:
- platform: wifi_info
ip_address:
name: "IP Address"
entity_category: diagnostic
ssid:
name: "Connected SSID"
entity_category: diagnostic
mac_address:
name: "Mac Address"
entity_category: diagnostic
- platform: template
name: 'Last Restart'
id: device_last_restart
icon: mdi:clock
entity_category: diagnostic
device_class: timestamp
time:
- platform: sntp
id: sntp_time
# Define the timezone of the device
timezone: "${timezone}"
# Change sync interval from default 5min to 6 hours (or as set in substitutions)
update_interval: ${sntp_update_interval}
# Set specific sntp servers to use
servers:
- "${sntp_server_1}"
- "${sntp_server_2}"
- "${sntp_server_3}"
# Publish the time the device was last restarted
on_time_sync:
then:
# Update last restart time, but only once.
- if:
condition:
lambda: 'return id(device_last_restart).state == "";'
then:
- text_sensor.template.publish:
id: device_last_restart
state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'