docker-apps/esphome/data/config/sthome-ut6.yaml

187 lines
4.6 KiB
YAML

substitutions:
name: sthome-ut6
friendly_name: "Sthome-Ut6"
esphome:
name: "${name}"
friendly_name: "${friendly_name}"
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "K3yXQthpXVNknD4RCLZX66gglNgDEFtj3H0r85VLBNs="
ota:
- platform: esphome
password: "5956a60f6cf40cf4b6b172e23f236572"
wifi:
#ssid: !secret wifi_ssid
#password: !secret wifi_password
# we will use local dns server for local dns resolution
domain: ".sthome.org"
networks:
- ssid: !secret wifi_ssid1
password: !secret wifi_password1
- ssid: !secret wifi_ssid2
password: !secret wifi_password2
- ssid: !secret wifi_ssid3
password: !secret wifi_password3
- ssid: !secret wifi_ssid4
password: !secret wifi_password4
- ssid: !secret wifi_ssid5
password: !secret wifi_password5
manual_ip:
# For faster connection startup, set a static IP address
# Set this to the IP of the ESP
static_ip: 10.0.2.6
gateway: 10.0.0.2
subnet: 255.255.240.0
dns1: 10.0.0.1
dns2: 10.0.0.2
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${friendly_name} Fallback Hotspot"
password: "HIjEc5P2BJhz"
captive_portal:
#####################################################################################
# Minimal flash writes, once per day
preferences:
flash_write_interval: 10min
# Sync time with Home Assistant
time:
- platform: homeassistant
id: homeassistant_time
# Blink LED for status, and also expose to HA as switch
#light:
# - platform: status_led
# name: "${friendly_name} status light"
# id: blueled
# pin:
# number: GPIO2
# inverted: yes
# restore_mode: RESTORE_DEFAULT_OFF
#
#script:
# - id: heartbeat
# mode: single
# then:
# - light.toggle: blueled
# - delay: 20 ms
# - light.toggle: blueled
#
# Heartbeat while connected to HA
#interval:
# - interval: 5s
# then:
# if:
# condition:
# api.connected:
# then:
# - script.execute: heartbeat
#
switch:
# Switch to restart the ESP
- platform: restart
name: ${friendly_name} Restart
- platform: gpio
pin: GPIO0
name: "Relay 1"
inverted: false
id: relay1
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- delay: 250ms
- switch.turn_off: relay1
- platform: gpio
pin: GPIO2
name: "Relay 2"
inverted: false
id: relay2
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- delay: 250ms
- switch.turn_off: relay2
text_sensor:
# Expose WiFi information as sensors
- platform: wifi_info
ip_address:
name: ${friendly_name} IP
mac_address:
name: ${friendly_name} Mac Address
# human readable update text sensor from sensor:uptime
- platform: template
name: Uptime
id: uptime_human
icon: mdi:clock-start
binary_sensor:
# - platform: gpio
# # Use your pins for something fun!
# pin:
# number: GPIO3
# inverted: true
# # HW: pull to ground with 10k, tie high through pump NC switch
# id: pump_alarm
# name: Drain Pump Alarm
# device_class: problem
- platform: status
# Status platform provides a connectivity sensor
name: "${friendly_name} - Status"
device_class: connectivity
sensor:
# Report wifi signal strength every 5 min if changed
- platform: wifi_signal
name: ${friendly_name} WiFi Signal
update_interval: 300s
filters:
- delta: 10%
# human readable uptime sensor output to the text sensor above
- platform: uptime
name: ${friendly_name} Uptime in Days
id: uptime_sensor_days
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor_days).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
# Pin assignments for ESP-01
# https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/
# 3v3 | | RX/GPIO3 - high at boot
# RST | | GPIO0 - pulled up, flash if low on boot
# EN | | GPIO2 - pulled up, blue led on if pulled down, must be high at boot
# TX | | GND
# ^ TX/GPIO1 - high at boot