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
+111 -105
View File
@@ -1,9 +1,13 @@
##########################################################################################
##########################################################################################
# POOL LIGHT POWER AND TIMER 2
# Controlled by a Athom Smart Plug V2
#
# v4.0 2026-01-31 Added Morning/Evening Timer Enable switches (gate timer windows)
#:########################################################################################:#
# TITLE: POOL LIGHT POWER AND TIMER 2
# zorruno.com layout v1.1 2026
#:########################################################################################:#
# REPO:
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-poollightpower2.yaml
#:########################################################################################:#
# VERSIONS:
# V4.1 2026-02-25 Updated yaml to zorruno layout V1.1
# V4.0 2026-01-31 Added Morning/Evening Timer Enable switches (gate timer windows)
# V3.0 2025-09-02 Pool Light mode controller fixes; Mode select forces Operation=ON;
# added Mode 0=OFF; select shows OFF when relay off; enforce 7s min OFF window
# V2.4 2025-06-15 Changed back to an Athom V1 (esp8266)
@@ -11,74 +15,73 @@
# V2.2 2025-06-14 Fixes to offline time when sntp/network unavailable
# V2.1 2025-06-12 Added select and button to chose modes, added countdown & startup to boost
# V2.0 2025-06-05 YAML Tidyups
#
# INSTRUCTIONS
# - 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)
# - Pool Light Mode can be set via the "Pool Light Mode" dropdown; selecting a mode forces Operation Mode = ON, and selecting "0=OFF" turns the relay OFF and returns Operation Mode to TIMER
# - Default values are set, but changed values are remembered in flash
# - It uses SNTP for time setting (but obviously only if wifi & networking are working)
# - It will default to an internal timer if no wifi. To reset internal timer, reboot the device at 12pm (noon)
# - If on a network and there is a MQTT server, you can set the on/off times via MQTT (See below commands)
# - You can set 4 modes ON/OFF/TIMER/BOOST via MQTT. Setting BOOST gives you a oneshot operation
# - Any new timer times set via MQTT will be remembered though a reboot
# - On startup, or a reboot, the device will always turn on for the BOOST Duration (BOOST mode, default 2 hours)
# - 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
# 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
# mqtt_timer_topic/morning-off/08:00 : Time device will go off
# mqtt_timer_topic/evening-on/09:00 : Time device will go on
# mqtt_timer_topic/evening-off/00:00 : Time device will go off
# mqtt_timer_topic/boost-time/0000 : Time in minutes device will temporarily go on for (1-1439)
# mqtt_timer_topic/operation/ON : Device permanently on
# mqtt_timer_topic/operation/OFF : Device permanently off
# mqtt_timer_topic/operation/TIMER : Device will obey timer settings
# mqtt_timer_topic/operation/BOOST : Turn on for (boost_duration) minutes then BOOST (also on startup)
#
# operation_mode:
# 0 = OFF
# 1 = ON
# 2 = TIMER
# 3 = BOOST
#
##########################################################################################
##########################################################################################
#:########################################################################################:#
# HARDWARE:
# Athom Smart Plug V2 (ESP8285) - used as pool light power controller
#:########################################################################################:#
# OPERATION NOTES:
# - Standalone timer style operation with morning/evening windows (no weekday/weekend settings)
# - Morning Timer Enable / Evening Timer Enable switches gate their timer windows (default ON and restored)
# - Uses SNTP for accurate time when available; falls back to an internal timer if offline
# - To reset internal timer when offline, reboot the device at 12pm (midday)
# - Pool Light Mode can be set via the "Pool Light Mode" dropdown:
# - Selecting a mode forces Operation Mode = ON
# - Selecting "0=OFF" turns relay OFF and returns Operation Mode to TIMER
# - If on a network and MQTT is available, on/off times and modes can be set via MQTT (see MQTT COMMANDS)
#:########################################################################################:#
# MQTT COMMANDS:
# Values are applied on update_interval (not immediately). Use HH:MM (24h).
# - ${mqtt_timer_topic}/morning-on payload "06:00"
# - ${mqtt_timer_topic}/morning-off payload "08:00"
# - ${mqtt_timer_topic}/evening-on payload "21:00"
# - ${mqtt_timer_topic}/evening-off payload "00:00"
# - ${mqtt_timer_topic}/boost-time payload "0000" (minutes 1-1439)
# - ${mqtt_timer_topic}/operation payload "ON","OFF","TIMER","BOOST"
#:########################################################################################:#
# OFFLINE NOTES:
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
# - Device remains controllable via MQTT (timeclock updates and operation mode)
# - Device continues running timer/mode logic locally
# b) MQTT OFFLINE (but WiFi/Network and HA API ONLINE)
# - Device remains controllable from Home Assistant via API (selects/buttons/switches)
# - MQTT timeclock updates and mode commands will not work while MQTT is down
# c) Entire WiFi/Network OFFLINE
# - No HA API and no MQTT control available
# - Device continues operating using last saved settings
# - Loss of network will drift the timeclocks; time of day can be reset by powering off then on again at 12pm (midday)
#:########################################################################################:#
##########################################################################################
# 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-poollightpower2"
friendly_name: "Pool Light Power"
description_comment: "Pool Light Power :: Athom Smart Plug Power V2"
description_comment: "Pool Light Power :: Athom Smart Plug Power V2 (Layout V1.1)"
device_area: "Outside" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
# Project Naming
project_name: "Athom Technology.Smart Plug V2" # Project Details
project_version: "v3.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
project_version: "v4.1" # Project version denotes release of yaml file, allowing checking of deployed vs latest version
# Passwords
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
static_ip_address: !secret esp-poollightpower2_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
log_level: "DEBUG" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
update_interval: "60s" # update time for for general sensors etc
# Device Settings
relay_icon: "mdi:power-socket-au"
current_limit : "10" # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
current_limit: "10" # Current Limit in Amps. AU Plug = 10. IL, BR, EU, UK, US Plug = 16.
mqtt_timer_topic: "viewroad-commands/poollight-timer" # Topics you will use to change stuff
boost_duration_default: "180" # Minutes to stay ON in BOOST mode before reverting to TIMER
morning_on_default: "450" # Default in minutes from midnight. Default 07:30 => 450
@@ -98,10 +101,10 @@ substitutions:
# Ignored modes bitmask: bit (mode_index-1). For 4 and 5 ignored -> (1<<3)|(1<<4) = 24.
ignored_modes_mask: "8288" # Ignore 6(32), 7(64), 14(8192) :: 32 + 64 + 8192 = 8288
##########################################################################################
#:########################################################################################:#
# PACKAGES: Included Common Packages
# https://esphome.io/components/packages.html
##########################################################################################
#:########################################################################################:#
packages:
##################################################
# MANDATORY packages (won't compile without them!)
@@ -114,6 +117,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}"
##################################################
# OPTIONAL packages (comment if you don't want them)
@@ -164,16 +168,16 @@ packages:
relay_restore_mode: "RESTORE_DEFAULT_OFF" # matches what you already use
power_plug_type: "${relay_icon}" # e.g. "mdi:power-socket-au"
##########################################################################################
# ESPHome
#:########################################################################################:#
# ESPHOME:
# https://esphome.io/components/esphome.html
##########################################################################################
#:########################################################################################:#
esphome:
name: "${device_name}"
friendly_name: "${friendly_name}"
comment: "${description_comment}" #Appears on the esphome page in HA
area: "${device_area}"
name_add_mac_suffix: False
name_add_mac_suffix: false
min_version: 2024.6.0
project:
name: "${project_name}"
@@ -189,10 +193,10 @@ esphome:
# - -fno-exceptions
# - -fno-rtti
##########################################################################################
# ESP Platform and Framework
# https://esphome.io/components/esp32.html
##########################################################################################
#:########################################################################################:#
# ESP PLATFORM AND FRAMEWORK:
# https://esphome.io/components/esp8266.html
#:########################################################################################:#
esp8266:
board: esp8285
restore_from_flash: true # mainly for calculating cumulative energy, but not that important here
@@ -203,22 +207,22 @@ preferences:
flash_write_interval: 10min
mdns:
disabled: False # binary size saving
disabled: false # binary size saving
##########################################################################################
# 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)
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/
##########################################################################################
#:########################################################################################:#
switch:
####################################################
# Timer Enable Switches
@@ -247,12 +251,11 @@ switch:
on_turn_off:
- script.execute: evaluate_relay_state
##########################################################################################
# Global Variables for use in automations etc
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
##########################################################################################
#:########################################################################################:#
# GLOBAL VARIABLES:
# https://esphome.io/components/globals.html
#:########################################################################################:#
globals:
# Tracks the time (in seconds from midnight) at the previous boot
- id: last_boot_time_s
type: int
@@ -355,7 +358,7 @@ globals:
restore_value: false
initial_value: "1"
# Bitmask of ignored modes (1..max_modes). Example: ignore 4 & 5 -> 24.
# Bitmask of ignored modes (1..max_modes). Example: ignore 4 and 5 -> 24.
- id: ignored_mask
type: int
restore_value: false
@@ -367,15 +370,14 @@ globals:
restore_value: false
initial_value: "false"
##########################################################################################
# Text Sensors
#:########################################################################################:#
# TEXT SENSOR COMPONENT:
# https://esphome.io/components/text_sensor/index.html
##########################################################################################
#:########################################################################################:#
text_sensor:
############################
# MQTT Subscriptions
############################
############################
# MQTT Subscriptions
############################
####################################################
# Subscribe to the Morning On time, format "HH:MM"
####################################################
@@ -396,6 +398,7 @@ text_sensor:
} else {
ESP_LOGW("timer","Invalid Morning On format: %s", x.c_str());
}
####################################################
# Morning Off time => "HH:MM"
####################################################
@@ -415,6 +418,7 @@ text_sensor:
} else {
ESP_LOGW("timer","Invalid Morning Off format: %s", x.c_str());
}
####################################################
# Evening On time => "HH:MM"
####################################################
@@ -434,6 +438,7 @@ text_sensor:
} else {
ESP_LOGW("timer","Invalid Evening On format: %s", x.c_str());
}
####################################################
# Evening Off time => "HH:MM"
####################################################
@@ -453,6 +458,7 @@ text_sensor:
} else {
ESP_LOGW("timer","Invalid Evening Off format: %s", x.c_str());
}
####################################################
# Boost duration => 1 - 1439
####################################################
@@ -577,10 +583,10 @@ text_sensor:
return { std::string(buff) };
update_interval: "${update_interval}"
##########################################################################################
# BINARY SENSORS
#:########################################################################################:#
# BINARY SENSORS:
# https://esphome.io/components/binary_sensor/
##########################################################################################
#:########################################################################################:#
binary_sensor:
- platform: template
id: relay_status
@@ -613,10 +619,10 @@ binary_sensor:
id(last_off_ms) = millis();
if (!id(mode_changing)) id(current_mode) = 0;
##########################################################################################
# Sensors
# https://esphome.io/components/text_sensor/index.html
##########################################################################################
#:########################################################################################:#
# SENSOR COMPONENT:
# https://esphome.io/components/sensor/
#:########################################################################################:#
sensor:
- platform: template
name: "Timeclock: Boost Duration"
@@ -663,10 +669,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"
@@ -701,10 +707,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"
@@ -725,7 +731,7 @@ select:
default: return std::string("OFF");
}
# when changed in HA, set mode & re-evaluate
# when changed in HA, set mode and re-evaluate
set_action:
- lambda: |-
if (x == "OFF") { id(operation_mode) = 0; }
@@ -859,10 +865,10 @@ select:
else:
- script.execute: change_to_desired_mode
#################################################################################################
# SCRIPT COMPONENT
#:########################################################################################:#
# SCRIPT COMPONENT:
# https://esphome.io/components/script.html
#################################################################################################
#:########################################################################################:#
script:
# Core: evaluate and drive the relay (with enforced min OFF window)
- id: evaluate_relay_state
@@ -1013,10 +1019,10 @@ script:
- lambda: |-
id(mode_changing) = false;
#################################################################################################
# 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"
@@ -1039,4 +1045,4 @@ interval:
//id(mqtt_client).publish("${mqtt_timer_topic}/operation", "TIMER");
}
}
- script.execute: evaluate_relay_state
- script.execute: evaluate_relay_state