Edit esp-loungebookshelfleds.yaml

This commit is contained in:
ESPHome Device Builder
2026-07-20 19:27:48 +12:00
parent d8bcf05bf6
commit 2b6b91f829
+31 -31
View File
@@ -6,6 +6,7 @@
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-loungebookshelfleds.yaml
#:########################################################################################:#
# VERSIONS:
# V2.2 2026-07-20 Simplified local MQTT command and status topics to the device root
# V2.1 2026-03-11 Updated yaml to zorruno layout V1.1
# V2.0 2025-09-15 A bunch of fixes and made it more standard across my devices
# V1.0 2025-08-17 First setup (and replacement of Tasmota)
@@ -48,10 +49,10 @@
# - Maximum ON time before automatic fade-down (1-48 h, 0 = no limit)
#
# MQTT COMMANDS:
# - ${mqtt_local_command_topic}/light/set = ON
# - ${mqtt_local_command_topic}/light/set = OFF
# - ${mqtt_local_command_topic} = ON
# - ${mqtt_local_command_topic} = OFF
# - State publishes to:
# - ${mqtt_local_status_topic}/light/state
# - ${mqtt_local_status_topic}
#:########################################################################################:#
# OFFLINE NOTES:
# a) Home Assistant offline (network and MQTT online):
@@ -84,7 +85,7 @@ substitutions:
# Project Naming
project_name: "Magichome Single Colour V1.1 LED Controller.Generic ESP8266" # Project details. Manufacturer before the dot, device after the dot.
project_version: "v2.1" # Project version denotes release of the YAML file, allowing checking of deployed vs latest version
project_version: "v2.2" # Project version denotes release of the YAML file, allowing checking of deployed vs latest version
# Passwords & Secrets (Unfortunately, you can't use substitutions inside secret names)
api_key: !secret esp-api_key # If using HA API
@@ -102,19 +103,19 @@ substitutions:
mqtt_local_device_command_OFF: "OFF"
# Device Specific Settings
log_level: "NONE" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (default), VERBOSE, VERY_VERBOSE
update_interval: "20s" # Update time for general sensors, etc.
led_gamma: "1.2" # Gamma from 1.2-3 is sensible to normalise the LED fading vs PWM
minimum_led_output: "1" # % If at this value or below, we will switch it completely off
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
pwm_frequency: "1000" # PWM output Frequency in Hz. High enough to avoid audible/visible artifacts
log_level: "NONE" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (default), VERBOSE, VERY_VERBOSE
update_interval: "20s" # Update time for general sensors, etc.
led_gamma: "1.2" # Gamma from 1.2-3 is sensible to normalise the LED fading vs PWM
minimum_led_output: "1" # % If at this value or below, we will switch it completely off
maximum_led_output: "90" # % Maximum output; it is sometimes nice to limit the output for longevity or aesthetics
max_on_default_hours: "24" # The maximum time the LEDs will be on, in case they get left on. 0 = no automatic turn-off
pwm_frequency: "1000" # PWM output Frequency in Hz. High enough to avoid audible/visible artifacts
# Device Specific GPIO (so we can easily update for other devices)
device_status_led: GPIO2
device_mosfet_out: GPIO12
device_usr_button: GPIO4 # if no button, this is just a fake/safeish choice so it compiles with the generic yaml
device_fading_led: GPIO13 # if no LED, this is just a fake/safeish choice so it compiles with the generic yaml
device_usr_button: GPIO4 # if no button, this is just a fake/safeish choice so it compiles with the generic yaml
device_fading_led: GPIO13 # if no LED, this is just a fake/safeish choice so it compiles with the generic yaml
#:########################################################################################:#
# PACKAGES:
@@ -132,8 +133,7 @@ packages:
local_ota_pass: "${ota_pass}"
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
common_api: !include
#file: common/api_common.yaml
common_api: !include #file: common/api_common.yaml
file: common/api_common_noencryption.yaml
vars:
local_api_key: "${api_key}"
@@ -245,12 +245,12 @@ globals:
- id: min_brightness_pct
type: int
restore_value: true
initial_value: "${minimum_led_output}" # start/finish at X%
initial_value: "${minimum_led_output}" # start/finish at X%
# Maximum Brightness % for LEDs (should never go beyond this)
- id: max_brightness_pct
type: int
restore_value: false
initial_value: "${maximum_led_output}" # hard cap; never exceed this
initial_value: "${maximum_led_output}" # hard cap; never exceed this
# The maximum time the lights will stay on, in hours. Just in case they are left on. 0 = forever
- id: max_on_hours
type: int
@@ -260,23 +260,23 @@ globals:
- id: led_gamma_f
type: float
restore_value: false
initial_value: ${led_gamma} # numeric at compile time
initial_value: ${led_gamma} # numeric at compile time
# Default Fading Up Time (Selectable and will be retained)
- id: ramp_up_ms # fade-in when turned ON
- id: ramp_up_ms # fade-in when turned ON
type: int
restore_value: true
initial_value: "5000" # 5 s
initial_value: "5000" # 5 s
# Default Fading Down Time (Selectable and will be retained)
- id: ramp_down_ms # fade-out when turned OFF
- id: ramp_down_ms # fade-out when turned OFF
type: int
restore_value: true
initial_value: "10000" # 10 s
initial_value: "10000" # 10 s
# Action on Restart. (0=Fade full, 1=Restore brightness, 2=Remain off)
- id: restart_mode
type: int
restore_value: true
initial_value: "0" # default = Fade Up to Full (so can be deployed with no other setup)
initial_value: "0" # default = Fade Up to Full (so can be deployed with no other setup)
# Determine last fade direction.
# true when you asked the light to end up ON (Ramp Up)
@@ -332,7 +332,7 @@ globals:
# Logs all log messages through the serial port and through MQTT topics.
#:########################################################################################:#
logger:
level: "${log_level}" # INFO Level suggested, or DEBUG for testing
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, Serial control)
#:########################################################################################:#
@@ -351,12 +351,12 @@ status_led:
mqtt:
on_message:
# Light control to ramp up
- topic: "${mqtt_local_command_topic}/light/set"
- topic: "${mqtt_local_command_topic}"
payload: "${mqtt_local_device_command_ON}"
then:
- switch.turn_on: mosfet_ramp_switch
# Light control to ramp down
- topic: "${mqtt_local_command_topic}/light/set"
- topic: "${mqtt_local_command_topic}"
payload: "${mqtt_local_device_command_OFF}"
then:
- switch.turn_off: mosfet_ramp_switch
@@ -570,7 +570,7 @@ output:
frequency: ${pwm_frequency}
- platform: gpio
id: green_led_out # Green LED
id: green_led_out # Green LED
pin:
number: ${device_fading_led}
inverted: false
@@ -593,7 +593,7 @@ light:
on_turn_on:
- output.turn_on: green_led_out
- mqtt.publish:
topic: "${mqtt_local_status_topic}/light/state"
topic: "${mqtt_local_status_topic}"
payload: "${mqtt_local_device_command_ON}"
retain: true
- lambda: |-
@@ -617,7 +617,7 @@ light:
lambda: "return !id(booting);"
then:
- mqtt.publish:
topic: "${mqtt_local_status_topic}/light/state"
topic: "${mqtt_local_status_topic}"
payload: "${mqtt_local_device_command_OFF}"
retain: true
- lambda: "id(ramp_switch_target_on) = false;"
@@ -957,7 +957,7 @@ script:
- id: deferred_restore_brightness
mode: restart
then:
- delay: 5s # let preferences/globals load and light settle
- delay: 5s # let preferences/globals load and light settle
- lambda: |-
// Use ONLY the exact last saved brightness.
float target = id(last_brightness_pct);
@@ -987,4 +987,4 @@ script:
- light.turn_off:
id: mosfet_leds
transition_length: 0s
# (Removed: output.turn_off: green_led_out) # make sure LED is off if no ramp
# (Removed: output.turn_off: green_led_out) # make sure LED is off if no ramp