various esphome changes
This commit is contained in:
@@ -10,27 +10,14 @@
|
||||
# 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)
|
||||
#############################################
|
||||
#############################################
|
||||
# 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)"
|
||||
@@ -39,35 +26,45 @@ substitutions:
|
||||
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
|
||||
|
||||
#############################################
|
||||
# Included Common Packages
|
||||
# https://esphome.io/components/esphome.html
|
||||
#############################################
|
||||
packages:
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_static_ip_address: ${static_ip_address}
|
||||
local_api_key: ${api_key}
|
||||
local_ota_pass: ${ota_pass}
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: ${friendly_name}
|
||||
local_update_interval: ${update_interval}
|
||||
|
||||
|
||||
# common_multiclick_pushbutton_Switch_2: !include
|
||||
# file: common/multiclick_pushbutton_common.yaml
|
||||
# vars:
|
||||
# local_name: "Button: Light Switch 2 (Cabinet)"
|
||||
# local_gpio: GPIO05 # Switch 2 for KS-811 Triple is GPIO5
|
||||
# local_relay_id: Relay_2 # ID of relay to turn on
|
||||
# local_singleclick_duration: 7200000 # 2 hrs in ms
|
||||
# common_multiclick_pushbutton_Switch_3: !include
|
||||
# file: common/multiclick_pushbutton_common.yaml
|
||||
# vars:
|
||||
# local_name: "Button: Extract Fan"
|
||||
# local_gpio: GPIO04 # Switch 3 for KS-811 Triple is GPIO4
|
||||
# local_relay_id: Relay_3 # ID of relay to turn on
|
||||
# local_singleclick_duration: 300000 # 5 minutes in ms
|
||||
# local_doubleclick_duration: 1800000 # 30 minutes in ms
|
||||
# local_tripleclick_duration: 7200000 # 2 hours in ms
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
# https://esphome.io/components/esphome.html
|
||||
@@ -76,14 +73,13 @@ 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
|
||||
board: esp01_1m
|
||||
|
||||
#############################################
|
||||
# ESPHome Logging Enable
|
||||
@@ -95,52 +91,6 @@ logger:
|
||||
#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
|
||||
@@ -152,35 +102,6 @@ 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
|
||||
@@ -191,6 +112,7 @@ status_led:
|
||||
number: GPIO2
|
||||
inverted: yes
|
||||
|
||||
|
||||
#############################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
@@ -201,25 +123,107 @@ binary_sensor:
|
||||
number: GPIO16
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Light Switch 1 (Main)"
|
||||
name: "Button: Light Switch 1 (Main)"
|
||||
on_press:
|
||||
- switch.toggle: Relay_1
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO05
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Light Switch 2 (Cabinet)"
|
||||
name: "Button: Light Switch 2 (Cabinet)"
|
||||
on_press:
|
||||
- switch.toggle: Relay_2
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO04
|
||||
number: GPIO4
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Extract Fan"
|
||||
on_press:
|
||||
- switch.toggle: Relay_3
|
||||
name: "Button: Light Switch 3 (Fan)"
|
||||
on_multi_click:
|
||||
# Single click: 1 press → relay on for 5 minutes
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_3).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_3
|
||||
else:
|
||||
- switch.turn_on: Relay_3
|
||||
- delay: 5min
|
||||
- switch.turn_off: Relay_3
|
||||
|
||||
# Double click: 2 presses → relay on for 30 minutes
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_3).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_3
|
||||
else:
|
||||
- switch.turn_on: Relay_3
|
||||
- delay: 30min
|
||||
- switch.turn_off: Relay_3
|
||||
|
||||
# Triple click: 3 presses → relay on for 4 hours
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_3).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_3
|
||||
else:
|
||||
- switch.turn_on: Relay_3
|
||||
- delay: 4h
|
||||
- switch.turn_off: Relay_3
|
||||
|
||||
# Hold: pressed for 1 second or more → relay toggles permanently
|
||||
- timing:
|
||||
- ON for at least 2s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_3).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_3
|
||||
else:
|
||||
- switch.turn_on: Relay_3
|
||||
|
||||
# - platform: gpio
|
||||
# pin:
|
||||
# number: GPIO04
|
||||
# mode: INPUT
|
||||
# inverted: True
|
||||
# name: "Button: Light Switch 3 (Fan)"
|
||||
# on_press:
|
||||
# - switch.toggle: Relay_3
|
||||
|
||||
# - platform: gpio
|
||||
# pin:
|
||||
# number: GPIO05
|
||||
# mode: INPUT
|
||||
# inverted: True
|
||||
# name: "Button: Light Switch 2 (Cabinet)"
|
||||
# on_press:
|
||||
# - switch.toggle: Relay_2
|
||||
|
||||
|
||||
#############################################
|
||||
# SWITCH COMPONENT
|
||||
@@ -227,38 +231,16 @@ binary_sensor:
|
||||
#############################################
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "Main Light"
|
||||
name: "Relay: Main Light"
|
||||
pin: GPIO13
|
||||
id: Relay_1
|
||||
- platform: gpio
|
||||
name: "Cabinet Light"
|
||||
name: "Relay: Cabinet Light"
|
||||
pin: GPIO12
|
||||
id: Relay_2
|
||||
- platform: gpio
|
||||
name: "Extract Fan"
|
||||
name: "Relay: 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: ""
|
||||
|
||||
|
Reference in New Issue
Block a user