more esphome devices and fixes

This commit is contained in:
root
2026-04-03 21:34:23 +13:00
parent e09931360a
commit f7bfa78835
96 changed files with 4870 additions and 2523 deletions
+310 -82
View File
@@ -1,14 +1,19 @@
##########################################################################################
##########################################################################################
# FRONT ENTRANCEWAY LED LIGHT CONTROLS
# File: esp-entranceoutsideledlights.yaml
#
# v1.0 - 2026-02-23 Initial version (converted from Tasmota)
#
# Hardware: H801 (ESP8266EX) 5-channel PWM MOSFET LED controller
#
###########################################################################################
# NOTES
#:########################################################################################:#
# TITLE: FRONT ENTRANCEWAY LED LIGHT CONTROLS
# zorruno.com layout v1.1 2026
#:########################################################################################:#
# REPO:
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-entranceoutsideledlights.yaml
#:########################################################################################:#
# VERSIONS:
# V1.2 2026-03-10 Added per-channel maximum ON timers with auto-dim-to-off, restart-on-ON, and moved defaults into substitutions
# V1.1 2026-03-10 Updated yaml to zorruno layout V1.1
# V1.0 2026-02-23 Initial version (converted from Tasmota)
#:########################################################################################:#
# HARDWARE:
# - H801 (ESP8266EX) 5-channel PWM MOSFET LED controller
#:########################################################################################:#
# OPERATION NOTES:
# - H801 PWM outputs (typical / ESPHome Devices):
# PWM1 / R -> GPIO15
# PWM2 / G -> GPIO13
@@ -23,43 +28,56 @@
# * Brightness slider 0-100% normalized to the per-channel hard limit
# * Ramp time (seconds) for a full 0 -> hard limit transition
# * Hard limit (percent) absolute cap for that channel
# * Maximum ON time (minutes) after which the channel dims to OFF
#
# - A fresh ON command restarts the countdown timer for that channel.
# - Setting channel brightness above 0 also restarts that channel timer.
#
# - Underlying PWM light entities are INTERNAL so HA cannot bypass the hard limit.
#
##########################################################################################
##########################################################################################
#:########################################################################################:#
# MQTT COMMANDS:
# - None (no device-specific MQTT commands in this YAML; common_mqtt is included for standardisation)
#:########################################################################################:#
# OFFLINE NOTES:
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
# - Local PWM control continues via HA entities if HA is offline (entities unavailable until HA returns)
# - Device continues running with last commanded PWM states
# - Any already-running max ON timer continues locally on the device
# b) MQTT OFFLINE (but WiFi/Network and HA API ONLINE)
# - No impact unless you rely on MQTT for diagnostics; local control via HA/API continues
# - Any already-running max ON timer continues locally on the device
# c) Entire WiFi/Network OFFLINE
# - No HA API and no MQTT connectivity
# - Outputs remain in their last driven state (until power loss/reboot)
# - Any already-running max ON timer continues locally on the device
# - Accurate time is NOT needed (SNTP not required for operation)
#:########################################################################################:#
##########################################################################################
# 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-entranceoutsideledlights"
friendly_name: "Front Entranceway LED Light controls"
description_comment: "H801 ESP8266 5-channel PWM LED controller (Entranceway)"
description_comment: "H801 ESP8266 5-channel PWM LED controller (Entranceway) (Layout V1.1)"
device_area: "Entranceway" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
# Project Naming
project_name: "H801.5CH PWM LED Controller"
project_version: "v1.0"
project_version: "v1.2"
# Passwords & Secrets
api_key: !secret esp-api_key
ota_pass: !secret esp-ota_pass
static_ip_address: !secret esp-entranceoutsideledlights_ip # unfortunately you can't use substitutions inside secrets names
#mqtt_command_main_topic: !secret mqtt_command_main_topic
#mqtt_status_main_topic: !secret mqtt_status_main_topic
# 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}
# MQTT LOCAL Controls (optional, kept for consistency with your templates)
#mqtt_local_device_name: "entranceoutsideledlights"
#mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}"
#mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}"
# Device Settings
log_level: "INFO" # NONE, ERROR, WARN, INFO, DEBUG, VERBOSE, VERY_VERBOSE
update_interval: "60s"
@@ -68,9 +86,28 @@ substitutions:
out1_name: "Main Entrance Outside LED Lights"
out2_name: "Number 16 LED Light"
out3_name: "Spare 3"
out4_name: "Spare 4"
out4_name: "Doorbell Illumination"
out5_name: "Spare 5"
# OUTPUT DEFAULT SETTINGS
out1_ramp_default_s: "2.0"
out2_ramp_default_s: "2.0"
out3_ramp_default_s: "2.0"
out4_ramp_default_s: "2.0"
out5_ramp_default_s: "2.0"
out1_max_limit_default_pct: "100"
out2_max_limit_default_pct: "100"
out3_max_limit_default_pct: "100"
out4_max_limit_default_pct: "100"
out5_max_limit_default_pct: "100"
out1_max_on_time_default_mins: "240"
out2_max_on_time_default_mins: "240"
out3_max_on_time_default_mins: "10"
out4_max_on_time_default_mins: "4"
out5_max_on_time_default_mins: "10"
# H801 PWM PINS (easy swap here if needed)
out1_pwm_pin: "GPIO15"
out2_pwm_pin: "GPIO13"
@@ -79,10 +116,11 @@ substitutions:
out5_pwm_pin: "GPIO4"
pwm_frequency: "1000 Hz"
##########################################################################################
#:########################################################################################:#
# PACKAGES: Included Common Packages
# https://esphome.io/components/packages.html
##########################################################################################
#:########################################################################################:#
packages:
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
common_wifi: !include
@@ -115,38 +153,43 @@ packages:
diag_debug: !include common/include_debug_diag_sensors.yaml
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
#############################################
# 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
min_version: 2025.11.0
area: ${device_area}
project:
name: ${project_name}
version: ${project_version}
#############################################
# ESP Platform and Framework
#:########################################################################################:#
# 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
min_version: 2025.11.0
area: "${device_area}"
project:
name: "${project_name}"
version: "${project_version}"
#:########################################################################################:#
# ESP PLATFORM AND FRAMEWORK:
# https://esphome.io/components/esp8266.html
#############################################
#:########################################################################################:#
esp8266:
board: esp01_1m
#############################################
# ESPHome Logging Enable
#:########################################################################################:#
# LOGGING:
# https://esphome.io/components/logger.html
#############################################
#:########################################################################################:#
logger:
level: ${log_level}
level: "${log_level}"
baud_rate: 0 # set to 0 for no logging via UART
##########################################################################################
# OUTPUTS (H801 PWM MOSFET CHANNELS)
##########################################################################################
#:########################################################################################:#
# OUTPUTS: H801 PWM MOSFET CHANNELS
# https://esphome.io/components/output/esp8266_pwm.html
#:########################################################################################:#
output:
- platform: esp8266_pwm
id: out1_pwm
@@ -173,9 +216,11 @@ output:
pin: ${out5_pwm_pin}
frequency: ${pwm_frequency}
##########################################################################################
# INTERNAL LIGHTS (do not expose to HA; use helper entities below)
##########################################################################################
#:########################################################################################:#
# LIGHTS: Internal raw PWM lights (not exposed to HA)
# https://esphome.io/components/light/monochromatic.html
#:########################################################################################:#
light:
- platform: monochromatic
id: out1_light_raw
@@ -212,9 +257,11 @@ light:
internal: true
restore_mode: RESTORE_DEFAULT_OFF
##########################################################################################
# GLOBALS (store "last non-zero" brightness per channel)
##########################################################################################
#:########################################################################################:#
# GLOBALS: Store "last non-zero" brightness per channel
# https://esphome.io/components/globals.html
#:########################################################################################:#
globals:
- id: out1_last_nonzero_pct
type: float
@@ -241,9 +288,11 @@ globals:
restore_value: true
initial_value: "100.0"
##########################################################################################
# SCRIPTS (apply normalized brightness + proportional ramping)
##########################################################################################
#:########################################################################################:#
# SCRIPTS: Apply normalized brightness + proportional ramping + per-channel auto-off timers
# https://esphome.io/components/script.html
#:########################################################################################:#
script:
#############################################
# OUT1
@@ -319,6 +368,14 @@ script:
call.set_transition_length(trans_ms);
call.perform();
- id: out1_auto_off_timer
mode: restart
parameters:
delay_ms: int
then:
- delay: !lambda "return delay_ms;"
- script.execute: out1_turn_off
#############################################
# OUT2
#############################################
@@ -393,6 +450,14 @@ script:
call.set_transition_length(trans_ms);
call.perform();
- id: out2_auto_off_timer
mode: restart
parameters:
delay_ms: int
then:
- delay: !lambda "return delay_ms;"
- script.execute: out2_turn_off
#############################################
# OUT3
#############################################
@@ -467,6 +532,14 @@ script:
call.set_transition_length(trans_ms);
call.perform();
- id: out3_auto_off_timer
mode: restart
parameters:
delay_ms: int
then:
- delay: !lambda "return delay_ms;"
- script.execute: out3_turn_off
#############################################
# OUT4
#############################################
@@ -541,6 +614,14 @@ script:
call.set_transition_length(trans_ms);
call.perform();
- id: out4_auto_off_timer
mode: restart
parameters:
delay_ms: int
then:
- delay: !lambda "return delay_ms;"
- script.execute: out4_turn_off
#############################################
# OUT5
#############################################
@@ -615,9 +696,19 @@ script:
call.set_transition_length(trans_ms);
call.perform();
##########################################################################################
# NUMBERS (brightness normalized to limit, plus per-channel ramp and hard limit)
##########################################################################################
- id: out5_auto_off_timer
mode: restart
parameters:
delay_ms: int
then:
- delay: !lambda "return delay_ms;"
- script.execute: out5_turn_off
#:########################################################################################:#
# NUMBER: Brightness normalized to limit, plus per-channel ramp, hard limit, and max ON time
# https://esphome.io/components/number/template.html
#:########################################################################################:#
number:
#############################################
# OUT1
@@ -632,7 +723,7 @@ number:
max_value: 30.0
step: 0.1
restore_value: true
initial_value: 2.0
initial_value: ${out1_ramp_default_s}
optimistic: true
set_action:
- script.execute: out1_apply_target
@@ -647,11 +738,24 @@ number:
max_value: 100
step: 1
restore_value: true
initial_value: 100
initial_value: ${out1_max_limit_default_pct}
optimistic: true
set_action:
- script.execute: out1_apply_target
- platform: template
id: out1_auto_off_mins
name: "${out1_name} Max ON Time"
icon: mdi:timer-lock-outline
entity_category: config
unit_of_measurement: "min"
min_value: 1
max_value: 720
step: 1
restore_value: true
initial_value: ${out1_max_on_time_default_mins}
optimistic: true
- platform: template
id: out1_brightness_pct
name: "${out1_name} Brightness"
@@ -667,6 +771,16 @@ number:
- lambda: |-
if (x > 0.0f) id(out1_last_nonzero_pct) = x;
- script.execute: out1_apply_target
- if:
condition:
lambda: |-
return x > 0.0f;
then:
- script.execute:
id: out1_auto_off_timer
delay_ms: !lambda "return (int) (id(out1_auto_off_mins).state * 60000.0f);"
else:
- script.stop: out1_auto_off_timer
#############################################
# OUT2
@@ -681,7 +795,7 @@ number:
max_value: 30.0
step: 0.1
restore_value: true
initial_value: 2.0
initial_value: ${out2_ramp_default_s}
optimistic: true
set_action:
- script.execute: out2_apply_target
@@ -696,11 +810,24 @@ number:
max_value: 100
step: 1
restore_value: true
initial_value: 100
initial_value: ${out2_max_limit_default_pct}
optimistic: true
set_action:
- script.execute: out2_apply_target
- platform: template
id: out2_auto_off_mins
name: "${out2_name} Max ON Time"
icon: mdi:timer-lock-outline
entity_category: config
unit_of_measurement: "min"
min_value: 1
max_value: 720
step: 1
restore_value: true
initial_value: ${out2_max_on_time_default_mins}
optimistic: true
- platform: template
id: out2_brightness_pct
name: "${out2_name} Brightness"
@@ -716,6 +843,16 @@ number:
- lambda: |-
if (x > 0.0f) id(out2_last_nonzero_pct) = x;
- script.execute: out2_apply_target
- if:
condition:
lambda: |-
return x > 0.0f;
then:
- script.execute:
id: out2_auto_off_timer
delay_ms: !lambda "return (int) (id(out2_auto_off_mins).state * 60000.0f);"
else:
- script.stop: out2_auto_off_timer
#############################################
# OUT3
@@ -730,7 +867,7 @@ number:
max_value: 30.0
step: 0.1
restore_value: true
initial_value: 2.0
initial_value: ${out3_ramp_default_s}
optimistic: true
set_action:
- script.execute: out3_apply_target
@@ -745,11 +882,24 @@ number:
max_value: 100
step: 1
restore_value: true
initial_value: 100
initial_value: ${out3_max_limit_default_pct}
optimistic: true
set_action:
- script.execute: out3_apply_target
- platform: template
id: out3_auto_off_mins
name: "${out3_name} Max ON Time"
icon: mdi:timer-lock-outline
entity_category: config
unit_of_measurement: "min"
min_value: 1
max_value: 720
step: 1
restore_value: true
initial_value: ${out3_max_on_time_default_mins}
optimistic: true
- platform: template
id: out3_brightness_pct
name: "${out3_name} Brightness"
@@ -765,6 +915,16 @@ number:
- lambda: |-
if (x > 0.0f) id(out3_last_nonzero_pct) = x;
- script.execute: out3_apply_target
- if:
condition:
lambda: |-
return x > 0.0f;
then:
- script.execute:
id: out3_auto_off_timer
delay_ms: !lambda "return (int) (id(out3_auto_off_mins).state * 60000.0f);"
else:
- script.stop: out3_auto_off_timer
#############################################
# OUT4
@@ -779,7 +939,7 @@ number:
max_value: 30.0
step: 0.1
restore_value: true
initial_value: 2.0
initial_value: ${out4_ramp_default_s}
optimistic: true
set_action:
- script.execute: out4_apply_target
@@ -794,11 +954,24 @@ number:
max_value: 100
step: 1
restore_value: true
initial_value: 100
initial_value: ${out4_max_limit_default_pct}
optimistic: true
set_action:
- script.execute: out4_apply_target
- platform: template
id: out4_auto_off_mins
name: "${out4_name} Max ON Time"
icon: mdi:timer-lock-outline
entity_category: config
unit_of_measurement: "min"
min_value: 1
max_value: 720
step: 1
restore_value: true
initial_value: ${out4_max_on_time_default_mins}
optimistic: true
- platform: template
id: out4_brightness_pct
name: "${out4_name} Brightness"
@@ -814,6 +987,16 @@ number:
- lambda: |-
if (x > 0.0f) id(out4_last_nonzero_pct) = x;
- script.execute: out4_apply_target
- if:
condition:
lambda: |-
return x > 0.0f;
then:
- script.execute:
id: out4_auto_off_timer
delay_ms: !lambda "return (int) (id(out4_auto_off_mins).state * 60000.0f);"
else:
- script.stop: out4_auto_off_timer
#############################################
# OUT5
@@ -828,7 +1011,7 @@ number:
max_value: 30.0
step: 0.1
restore_value: true
initial_value: 2.0
initial_value: ${out5_ramp_default_s}
optimistic: true
set_action:
- script.execute: out5_apply_target
@@ -843,11 +1026,24 @@ number:
max_value: 100
step: 1
restore_value: true
initial_value: 100
initial_value: ${out5_max_limit_default_pct}
optimistic: true
set_action:
- script.execute: out5_apply_target
- platform: template
id: out5_auto_off_mins
name: "${out5_name} Max ON Time"
icon: mdi:timer-lock-outline
entity_category: config
unit_of_measurement: "min"
min_value: 1
max_value: 720
step: 1
restore_value: true
initial_value: ${out5_max_on_time_default_mins}
optimistic: true
- platform: template
id: out5_brightness_pct
name: "${out5_name} Brightness"
@@ -863,14 +1059,26 @@ number:
- lambda: |-
if (x > 0.0f) id(out5_last_nonzero_pct) = x;
- script.execute: out5_apply_target
- if:
condition:
lambda: |-
return x > 0.0f;
then:
- script.execute:
id: out5_auto_off_timer
delay_ms: !lambda "return (int) (id(out5_auto_off_mins).state * 60000.0f);"
else:
- script.stop: out5_auto_off_timer
##########################################################################################
# SWITCHES (On/Off that respects ramping; brightness slider remains unchanged when off)
##########################################################################################
#:########################################################################################:#
# SWITCH: On/Off that respects ramping; brightness slider remains unchanged when off
# https://esphome.io/components/switch/template.html
#:########################################################################################:#
switch:
- platform: template
id: out1_switch
name: ${out1_name}
name: "${out1_name}"
icon: mdi:lightbulb
lambda: |-
return id(out1_light_raw).current_values.is_on();
@@ -885,12 +1093,16 @@ switch:
value: !lambda "return id(out1_last_nonzero_pct);"
else:
- script.execute: out1_apply_target
- script.execute:
id: out1_auto_off_timer
delay_ms: !lambda "return (int) (id(out1_auto_off_mins).state * 60000.0f);"
turn_off_action:
- script.stop: out1_auto_off_timer
- script.execute: out1_turn_off
- platform: template
id: out2_switch
name: ${out2_name}
name: "${out2_name}"
icon: mdi:lightbulb
lambda: |-
return id(out2_light_raw).current_values.is_on();
@@ -905,12 +1117,16 @@ switch:
value: !lambda "return id(out2_last_nonzero_pct);"
else:
- script.execute: out2_apply_target
- script.execute:
id: out2_auto_off_timer
delay_ms: !lambda "return (int) (id(out2_auto_off_mins).state * 60000.0f);"
turn_off_action:
- script.stop: out2_auto_off_timer
- script.execute: out2_turn_off
- platform: template
id: out3_switch
name: ${out3_name}
name: "${out3_name}"
icon: mdi:lightbulb
lambda: |-
return id(out3_light_raw).current_values.is_on();
@@ -925,12 +1141,16 @@ switch:
value: !lambda "return id(out3_last_nonzero_pct);"
else:
- script.execute: out3_apply_target
- script.execute:
id: out3_auto_off_timer
delay_ms: !lambda "return (int) (id(out3_auto_off_mins).state * 60000.0f);"
turn_off_action:
- script.stop: out3_auto_off_timer
- script.execute: out3_turn_off
- platform: template
id: out4_switch
name: ${out4_name}
name: "${out4_name}"
icon: mdi:lightbulb
lambda: |-
return id(out4_light_raw).current_values.is_on();
@@ -945,12 +1165,16 @@ switch:
value: !lambda "return id(out4_last_nonzero_pct);"
else:
- script.execute: out4_apply_target
- script.execute:
id: out4_auto_off_timer
delay_ms: !lambda "return (int) (id(out4_auto_off_mins).state * 60000.0f);"
turn_off_action:
- script.stop: out4_auto_off_timer
- script.execute: out4_turn_off
- platform: template
id: out5_switch
name: ${out5_name}
name: "${out5_name}"
icon: mdi:lightbulb
lambda: |-
return id(out5_light_raw).current_values.is_on();
@@ -965,5 +1189,9 @@ switch:
value: !lambda "return id(out5_last_nonzero_pct);"
else:
- script.execute: out5_apply_target
- script.execute:
id: out5_auto_off_timer
delay_ms: !lambda "return (int) (id(out5_auto_off_mins).state * 60000.0f);"
turn_off_action:
- script.stop: out5_auto_off_timer
- script.execute: out5_turn_off