Files
zorruno-homeassistant/esphome/esp-downstbathswitch.yaml
2025-03-03 22:30:15 +13:00

265 lines
8.8 KiB
YAML

#############################################
#############################################
# DOWNSTAIRS BATHROOM MAIN LIGHTSWITCH
# Zemismart KS-811 Triple push button
#
# V1.0 2025-02-14 Initial Version
#
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
#
# INSTRUCTIONS
# -
#
# MQTT Commands
# Values will be set in place on the update_interval time, not immediately
# Use 00:00 in 24hr format for time setting. Note there is no weekday/weekend setting
# mqtt_timer_topic/morning-on/06:00 : Time towel rail will go on
# mqtt_timer_topic/morning-off/08:00 : Time towel rail will go off
# mqtt_timer_topic/evening-on/09:00 : Time towel rail will go on
# mqtt_timer_topic/evening-off/00:00 : Time towel rail will go off
# mqtt_timer_topic/operation/ON : Towel rail permanently on
# mqtt_timer_topic/operation/OFF : Towel rail permanently off
# mqtt_timer_topic/operation/TIMER : Towel rail will obey timer settings
# mqtt_timer_topic/operation/STARTUP : Turn on for 2 hours then TIMER (also on startup)
#
#############################################
#############################################
substitutions:
#############################################
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
#############################################
devicename: "esp-downstbathswitch"
friendly_name: "Downstairs Bath Lightswitch"
description_comment: "Downstairs Bathroom Main Lightswitch using a Zemismart KS-811 Triple Push Button. Main Light (1), Cabinet Light (2), Extract Fan (3)"
api_key: !secret esp-downstbathswitch_api_key # unfortunately you can't use substitutions inside secrets names
ota_pass: !secret esp-downstbathswitch_ota_pass # unfortunately you can't use substitutions inside secrets names
static_ip_address: !secret esp-downstbathswitch_ip
#mqtt_timer_topic: "viewroad-commands/masterbath-towelrail" # Topics you will use to change stuff
#startup_duration: "120" # Minutes to stay ON in STARTUP mode before reverting to TIMER
#timezone: "Pacific/Auckland" # For setting clock with snmp
#############################################
# MY SYSTEM VARIABLE SUBSTITUTIONS
#############################################
wifi_ssid: !secret ha_wifi_ssid
wifi_password: !secret ha_wifi_password
fallback_ap_password: !secret fallback_ap_password
# Add these if we are giving it a static ip, or remove them in the Wifi section
static_ip_subnet: !secret ha_wifi_subnet
static_ip_gateway: !secret ha_wifi_gateway
mqtt_server: !secret ha_mqtt_server
mqtt_username: !secret ha_mqtt_username
mqtt_password: !secret ha_mqtt_password
mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like
# Add these if we are using the internal web server (this is pretty processor intensive)
#web_server_username: !secret web_server_username
#web_server_password: !secret web_server_password
update_interval: 60s # update time for for general sensors etc
#############################################
# ESPHome
# https://esphome.io/components/esphome.html
#############################################
esphome:
name: ${devicename}
friendly_name: ${friendly_name}
comment: ${description_comment} #Appears on the esphome page in HA
#############################################
# ESP Platform and Framework
# https://esphome.io/components/esp32.html
#############################################
esp8266:
board: esp01_1m # The original sonoff basic
#############################################
# ESPHome Logging Enable
# https://esphome.io/components/logger.html
#############################################
logger:
level: INFO #INFO Level suggested, or DEBUG for testing
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
#esp8266_store_log_strings_in_flash: false
#tx_buffer_size: 64
#############################################
# Enable the Home Assistant API
# https://esphome.io/components/api.html
#############################################
api:
encryption:
key: ${api_key}
#############################################
# Enable Over the Air Update Capability
# https://esphome.io/components/ota.html?highlight=ota
#############################################
ota:
- platform: esphome
password: ${ota_pass}
#############################################
# Safe Mode
# Safe mode will detect boot loops
# https://esphome.io/components/safe_mode
#############################################
safe_mode:
#############################################
# Wifi Settings
# https://esphome.io/components/wifi.html
#
# Power Save mode (can reduce wifi reliability)
# NONE (least power saving, Default for ESP8266)
# LIGHT (Default for ESP32)
# HIGH (most power saving)
#############################################
wifi:
ssid: ${wifi_ssid}
password: ${wifi_password}
#power_save_mode: LIGHT # https://esphome.io/components/wifi.html#wifi-power-save-mode
manual_ip: # optional static IP address
static_ip: ${static_ip_address}
gateway: ${static_ip_gateway}
subnet: ${static_ip_subnet}
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
ssid: ${devicename} AP
password: ${fallback_ap_password}
ap_timeout: 30min # Time until it brings up fallback AP. default is 1min
captive_portal: # extra fallback mechanism for when connecting if the configured WiFi fails
#############################################
# Real time clock time source for ESPHome
# If it's invalid, we fall back to an internal clock
# https://esphome.io/components/time/
# https://esphome.io/components/time/sntp
#############################################
time:
- platform: sntp
id: sntp_time
#############################################
# MQTT Monitoring
# https://esphome.io/components/mqtt.html?highlight=mqtt
# MUST also have api enabled if you enable MQTT
#############################################
mqtt:
broker: ${mqtt_server}
topic_prefix: ${mqtt_topic}/${devicename}
username: ${mqtt_username}
password: ${mqtt_password}
#discovery: True # enable entity discovery (true is default)
#discover_ip: True # enable device discovery (true is default)
#############################################
# Global Variables for use in automations etc
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
#############################################
#globals:
#############################################
# TEXT SENSORS
# https://esphome.io/components/text_sensor/
#############################################
text_sensor:
- platform: version
name: ${friendly_name} Version
- platform: wifi_info
ip_address:
name: ${friendly_name} IP Address
#############################################
# STATUS LED
# https://esphome.io/components/status_led.html
#############################################
status_led:
pin:
number: GPIO2
inverted: yes
#############################################
# BINARY SENSORS
# https://esphome.io/components/binary_sensor/
#############################################
binary_sensor:
- platform: gpio
pin:
number: GPIO16
mode: INPUT
inverted: True
name: "Light Switch 1 (Main)"
on_press:
- switch.toggle: Relay_1
- platform: gpio
pin:
number: GPIO05
mode: INPUT
inverted: True
name: "Light Switch 2 (Cabinet)"
on_press:
- switch.toggle: Relay_2
- platform: gpio
pin:
number: GPIO04
mode: INPUT
inverted: True
name: "Extract Fan"
on_press:
- switch.toggle: Relay_3
#############################################
# SWITCH COMPONENT
# https://esphome.io/components/switch/
#############################################
switch:
- platform: gpio
name: "Main Light"
pin: GPIO13
id: Relay_1
- platform: gpio
name: "Cabinet Light"
pin: GPIO12
id: Relay_2
- platform: gpio
name: "Extract Fan"
pin: GPIO14
id: Relay_3
#############################################
# GENERAL SENSORS
# https://esphome.io/components/sensor/
#############################################
sensor:
- platform: uptime # Uptime for this device
name: ${friendly_name} Uptime
update_interval: ${update_interval}
entity_category: "diagnostic"
- platform: wifi_signal # Wifi Strength
name: ${friendly_name} Wifi Signal dB
id: wifi_signal_db
update_interval: ${update_interval}
entity_category: "diagnostic"
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: ${friendly_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: ""