yaml layout updates to v1.x

This commit is contained in:
root
2026-02-25 21:05:21 +13:00
parent 61b0c64a1e
commit a8d2927274
44 changed files with 6521 additions and 4689 deletions
+78 -58
View File
@@ -1,15 +1,19 @@
#############################################
#############################################
# MASTER BATHROOM HEATED TOWEL RAIL
# Controlled by a Sonoff Basic
#
#:########################################################################################:#
# TITLE: MASTER BATHROOM HEATED TOWEL RAIL
# zorruno.com layout v1.0 2026
#:########################################################################################:#
# VERSIONS:
# V2.2 2026-01-30 Added Morning/Evening Timer enable switches (gate timer windows)
# V2.1 2025-06-12 Added select and button to chose modes, added countdown & startup to boost
# V2.0 2025-06-05 YAML Tidyups
# V1.1 2025-04-12 Fixes to timers and offline modes
# V1.0 2025-02-14 Initial Version
#
# INSTRUCTIONS
#:########################################################################################:#
# HARDWARE:
# Controlled by a Sonoff Basic
# pinout/schematic: https://devices.esphome.io/devices/sonoff-basic-r4-v1.0/
#:########################################################################################:#
# OPERATION NOTES:
# - It allows the device to work in a standalone timer style operation
# - The timer has a morning and evening time (but no weekday/weekend settings)
# - Morning Timer Enable / Evening Timer Enable switches gate their timer windows (default ON and restored on reboot)
@@ -23,8 +27,8 @@
# - TIMER mode will always be switched on after BOOST mode is complete
# - Home Assistant entities are set so that BOOST mode can be pressed with a button and other modes selectable with a dropdown
# - If you need it ON continuously with no MQTT, toggle power ON/OFF 4 times within 30 seconds (with ~2 secs in between to allow it to boot)
#
# MQTT Commands
#:########################################################################################:#
# 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 device will go on
@@ -42,14 +46,25 @@
# 1 = ON
# 2 = TIMER
# 3 = BOOST
#
##########################################################################################
##########################################################################################
#:########################################################################################:#
# OFFLINE NOTES:
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
# - The towel rail will stick to its assigned schedule (and should remember on reboot)
# - Shedule times and on/off switching can still occur via MQTT
# - Other switches such as the IR Heater/Fan combo can still command the towel rail
# b) HA/MQTT OFFLINE
# With no automation controllers, the HTR will still remember its timing functions, and will
# turn on once or twice per day. If internet/wifi is still available, timing will be accurate.
# c) Internet/Wifi OFFLINE
# The HTR will still come on once or twice per day (depending on previous settings) however
# timing will likely shift. To make timing more accurate, it can be powered down then up at 12pm.
# Obviously this may drift again over time.
#:########################################################################################:#
##########################################################################################
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
#:########################################################################################:#
# SUBSTITUTIONS: Specific device variable substitutions
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
##########################################################################################
#:########################################################################################:#
substitutions:
# Device Naming
device_name: "esp-masterbathtowelrail"
@@ -66,6 +81,10 @@ substitutions:
ota_pass: !secret esp-masterbathtowelrail_ota_pass # unfortunately you can't use substitutions inside secrets names
static_ip_address: !secret esp-masterbathtowelrail_ip
# If we are changing IP addresses, you must update the current IP address here, otherwise it remains
# Don't forget to switch it back when changed.
current_ip_address: ${static_ip_address}
# Device Settings
relay_icon: "mdi:heating-coil"
log_level: "ERROR" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
@@ -79,10 +98,10 @@ substitutions:
evening_on_default: "1260" # Default in minutes from midnight. Default 21:00 => 1260
evening_off_default: "1439" # Default in minutes from midnight. Default 23:59 => 1439 => 1440 is midnight
##########################################################################################
#:########################################################################################:#
# PACKAGES: Included Common Packages
# https://esphome.io/components/packages.html
##########################################################################################
#:########################################################################################:#
packages:
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
common_wifi: !include
@@ -91,6 +110,7 @@ packages:
local_device_name: "${device_name}"
local_static_ip_address: "${static_ip_address}"
local_ota_pass: "${ota_pass}"
local_current_ip_address: "${current_ip_address}"
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
common_api: !include
@@ -116,10 +136,10 @@ packages:
#diag_debug: !include common/include_debug_diag_sensors.yaml
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
#############################################
# ESPHome
#:########################################################################################:#
# ESPHOME:
# https://esphome.io/components/esphome.html
#############################################
#:########################################################################################:#
esphome:
name: "${device_name}"
friendly_name: "${friendly_name}"
@@ -175,10 +195,11 @@ esphome:
}
- script.execute: evaluate_relay_state # Check what the relay should be doing straight away
#############################################
# ESP Platform and Framework
# https://esphome.io/components/esp32.html
#############################################
#:########################################################################################:#
# ESP PLATFORM AND FRAMEWORK:
# https://esphome.io/components/esp8266/
# https://esphome.io/components/esp32/
#:########################################################################################:#
esp8266:
board: esp01_1m # The original sonoff basic
restore_from_flash: true # restore some values on reboot
@@ -189,21 +210,21 @@ preferences:
mdns:
disabled: true
##########################################################################################
# ESPHome Logging Enable
#:########################################################################################:#
# LOGGING: ESPHome Logging Enable
# https://esphome.io/components/logger.html
##########################################################################################
#:########################################################################################:#
logger:
level: "${log_level}" #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
####################################################
# SWITCH COMPONENT
#:########################################################################################:#
# SWITCH COMPONENT:
# https://esphome.io/components/switch/
# Relay Switch (Sonoff Basic Relay on GPIO12)
####################################################
#:########################################################################################:#
switch:
- platform: gpio
name: "Towel Rail Power"
@@ -239,12 +260,11 @@ switch:
on_turn_off:
- script.execute: evaluate_relay_state
##########################################################################################
# Global Variables for use in automations etc
#:########################################################################################:#
# GLOBAL VARIABLES:
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
##########################################################################################
#:########################################################################################:#
globals:
# Tracks the time (in seconds from midnight) at the previous boot
- id: last_boot_time_s
type: int
@@ -309,10 +329,10 @@ globals:
restore_value: false
initial_value: "0"
##########################################################################################
# Text Sensors
#:########################################################################################:#
# TEST SENSORS COMPONENT:
# https://esphome.io/components/text_sensor/index.html
##########################################################################################
#:########################################################################################:#
text_sensor:
############################
@@ -514,10 +534,10 @@ text_sensor:
return { std::string(buff) };
update_interval: "${update_interval}"
##########################################################################################
# NUMBER COMPONENT
#:########################################################################################:#
# NUMBER COMPONENT:
# https://esphome.io/components/number/index.html
##########################################################################################
#:########################################################################################:#
number:
# A value for setting operation mode via HTTP
- platform: template
@@ -532,10 +552,10 @@ number:
// x holds the incoming value (0-3)
id(operation_mode) = int(x);
##########################################################################################
# BINARY SENSORS
#:########################################################################################:#
# BINARY SENSORS:
# https://esphome.io/components/binary_sensor/
##########################################################################################
#:########################################################################################:#
binary_sensor:
- platform: gpio
pin:
@@ -566,10 +586,10 @@ binary_sensor:
lambda: |-
return id(relay).state;
##########################################################################################
# Sensors
#:########################################################################################:#
# SENSORS COMPONENT:
# https://esphome.io/components/text_sensor/index.html
##########################################################################################
#:########################################################################################:#
sensor:
- platform: template
name: "Timeclock: Boost Duration"
@@ -616,10 +636,10 @@ sensor:
// never return negative
return rem > 0 ? rem : 0;
#################################################################################################
# BUTTON COMPONENT
#:###############################################################################################:#
# BUTTON COMPONENT:
# https://esphome.io/components/button/index.html
#################################################################################################
#:###############################################################################################:#
button:
- platform: template
name: "Boost now"
@@ -654,10 +674,10 @@ button:
- switch.turn_on: evening_timer_enable
- script.execute: evaluate_relay_state
#################################################################################################
# SELECT COMPONENT
#:###############################################################################################:#
# SELECT COMPONENT:
# https://esphome.io/components/select/index.html
#################################################################################################
#:###############################################################################################:#
select:
- platform: template
name: "Operation Mode"
@@ -690,10 +710,10 @@ select:
}
- script.execute: evaluate_relay_state
#################################################################################################
# SCRIPT COMPONENT
#:###############################################################################################:#
# SCRIPT COMPONENT:
# https://esphome.io/components/script.html
#################################################################################################
#:###############################################################################################:#
# Script: evaluate and drive the relay
script:
- id: evaluate_relay_state
@@ -741,10 +761,10 @@ script:
else id(relay).turn_off();
}
#################################################################################################
# INTERVAL COMPONENT
#:###############################################################################################:#
# INTERVAL COMPONENT:
# https://esphome.io/components/interval.html
#################################################################################################
#:###############################################################################################:#
# Interval: bumps time (even if no SNTP), then calls the script to evaluate relay state
interval:
- interval: "1min"