Edit esp-downstairskitchleds.yaml
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-downstairskitchleds.yaml
|
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-downstairskitchleds.yaml
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# VERSIONS:
|
# VERSIONS:
|
||||||
|
# v2.2 2026-07-20 Simplified local MQTT command and status topics to the device root
|
||||||
# v2.1 2026-02-25 Updated yaml to zorruno layout V1.1
|
# v2.1 2026-02-25 Updated yaml to zorruno layout V1.1
|
||||||
# v2.0 2025-09-15 A bunch of fixes.
|
# v2.0 2025-09-15 A bunch of fixes.
|
||||||
# v1.5 2025-09-04 Adopt ramped "Restore Brightness" (0->last non-zero), avoid boot blip (ALWAYS_OFF + high-priority on_boot),
|
# v1.5 2025-09-04 Adopt ramped "Restore Brightness" (0->last non-zero), avoid boot blip (ALWAYS_OFF + high-priority on_boot),
|
||||||
@@ -60,12 +61,12 @@
|
|||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# MQTT COMMANDS:
|
# MQTT COMMANDS:
|
||||||
# - Command topic:
|
# - Command topic:
|
||||||
# ${mqtt_local_command_topic}/light/set
|
# ${mqtt_local_command_topic}
|
||||||
# Payload "${mqtt_local_device_command_ON}" -> fade up (switch ON)
|
# Payload "${mqtt_local_device_command_ON}" -> fade up (switch ON)
|
||||||
# Payload "${mqtt_local_device_command_OFF}" -> fade down (switch OFF)
|
# Payload "${mqtt_local_device_command_OFF}" -> fade down (switch OFF)
|
||||||
#
|
#
|
||||||
# - Status topic:
|
# - Status topic:
|
||||||
# ${mqtt_local_status_topic}/light/state
|
# ${mqtt_local_status_topic}
|
||||||
# Payload "${mqtt_local_device_command_ON}" / "${mqtt_local_device_command_OFF}"
|
# Payload "${mqtt_local_device_command_ON}" / "${mqtt_local_device_command_OFF}"
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# OFFLINE NOTES:
|
# OFFLINE NOTES:
|
||||||
@@ -81,7 +82,6 @@
|
|||||||
# - Accurate time is NOT needed (SNTP not needed)
|
# - Accurate time is NOT needed (SNTP not needed)
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
|
|
||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# SUBSTITUTIONS: Specific device variable substitutions
|
# SUBSTITUTIONS: Specific device variable substitutions
|
||||||
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
|
||||||
@@ -95,7 +95,7 @@ substitutions:
|
|||||||
|
|
||||||
# Project Naming
|
# Project Naming
|
||||||
project_name: "Sinilink.XY-WFMS" # Project details. Manufacturer before the dot, device after the dot.
|
project_name: "Sinilink.XY-WFMS" # 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)
|
# Passwords & Secrets (Unfortunately, you can't use substitutions inside secret names)
|
||||||
api_key: !secret esp-api_key
|
api_key: !secret esp-api_key
|
||||||
@@ -145,8 +145,7 @@ packages:
|
|||||||
local_current_ip_address: "${current_ip_address}"
|
local_current_ip_address: "${current_ip_address}"
|
||||||
|
|
||||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||||
common_api: !include
|
common_api: !include #file: common/api_common.yaml
|
||||||
#file: common/api_common.yaml
|
|
||||||
file: common/api_common_noencryption.yaml
|
file: common/api_common_noencryption.yaml
|
||||||
vars:
|
vars:
|
||||||
local_api_key: "${api_key}"
|
local_api_key: "${api_key}"
|
||||||
@@ -193,32 +192,32 @@ esphome:
|
|||||||
# Mode 0: Fade up to full (obeys fade settings; no on/off flicker)
|
# Mode 0: Fade up to full (obeys fade settings; no on/off flicker)
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(restart_mode) == 0;'
|
lambda: "return id(restart_mode) == 0;"
|
||||||
then:
|
then:
|
||||||
- lambda: 'id(ramp_switch_target_on) = true;'
|
- lambda: "id(ramp_switch_target_on) = true;"
|
||||||
- script.execute: ramp_on_script
|
- script.execute: ramp_on_script
|
||||||
|
|
||||||
# Mode 1: Restore Brightness (deferred to avoid races)
|
# Mode 1: Restore Brightness (deferred to avoid races)
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(restart_mode) == 1;'
|
lambda: "return id(restart_mode) == 1;"
|
||||||
then:
|
then:
|
||||||
- script.execute: deferred_restore_brightness
|
- script.execute: deferred_restore_brightness
|
||||||
|
|
||||||
# Mode 2: Remain Off (no blip; stays off)
|
# Mode 2: Remain Off (no blip; stays off)
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(restart_mode) == 2;'
|
lambda: "return id(restart_mode) == 2;"
|
||||||
then:
|
then:
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- lambda: 'id(ramp_switch_target_on) = false;'
|
- lambda: "id(ramp_switch_target_on) = false;"
|
||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 0s
|
transition_length: 0s
|
||||||
|
|
||||||
# Boot complete: allow OFF handlers again
|
# Boot complete: allow OFF handlers again
|
||||||
- lambda: 'id(booting) = false;'
|
- lambda: "id(booting) = false;"
|
||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# ESP PLATFORM AND FRAMEWORK
|
# ESP PLATFORM AND FRAMEWORK
|
||||||
@@ -358,13 +357,13 @@ status_led:
|
|||||||
mqtt:
|
mqtt:
|
||||||
on_message:
|
on_message:
|
||||||
# Light control to ramp up
|
# Light control to ramp up
|
||||||
- topic: "${mqtt_local_command_topic}/light/set"
|
- topic: "${mqtt_local_command_topic}"
|
||||||
payload: "${mqtt_local_device_command_ON}"
|
payload: "${mqtt_local_device_command_ON}"
|
||||||
then:
|
then:
|
||||||
- switch.turn_on: mosfet_ramp_switch
|
- switch.turn_on: mosfet_ramp_switch
|
||||||
|
|
||||||
# Light control to ramp down
|
# Light control to ramp down
|
||||||
- topic: "${mqtt_local_command_topic}/light/set"
|
- topic: "${mqtt_local_command_topic}"
|
||||||
payload: "${mqtt_local_device_command_OFF}"
|
payload: "${mqtt_local_device_command_OFF}"
|
||||||
then:
|
then:
|
||||||
- switch.turn_off: mosfet_ramp_switch
|
- switch.turn_off: mosfet_ramp_switch
|
||||||
@@ -492,7 +491,7 @@ binary_sensor:
|
|||||||
on_press:
|
on_press:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(ramp_switch_target_on);'
|
lambda: "return id(ramp_switch_target_on);"
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(ramp_switch_target_on) = false;
|
id(ramp_switch_target_on) = false;
|
||||||
@@ -589,7 +588,7 @@ light:
|
|||||||
on_turn_on:
|
on_turn_on:
|
||||||
- output.turn_on: green_led_out
|
- output.turn_on: green_led_out
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}/light/state"
|
topic: "${mqtt_local_status_topic}"
|
||||||
payload: "${mqtt_local_device_command_ON}"
|
payload: "${mqtt_local_device_command_ON}"
|
||||||
retain: true
|
retain: true
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
@@ -599,7 +598,7 @@ light:
|
|||||||
- script.stop: max_on_watchdog
|
- script.stop: max_on_watchdog
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(max_on_hours) > 0;'
|
lambda: "return id(max_on_hours) > 0;"
|
||||||
then:
|
then:
|
||||||
- script.execute: max_on_watchdog
|
- script.execute: max_on_watchdog
|
||||||
|
|
||||||
@@ -607,13 +606,13 @@ light:
|
|||||||
- output.turn_off: green_led_out
|
- output.turn_off: green_led_out
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return !id(booting);'
|
lambda: "return !id(booting);"
|
||||||
then:
|
then:
|
||||||
- mqtt.publish:
|
- mqtt.publish:
|
||||||
topic: "${mqtt_local_status_topic}/light/state"
|
topic: "${mqtt_local_status_topic}"
|
||||||
payload: "${mqtt_local_device_command_OFF}"
|
payload: "${mqtt_local_device_command_OFF}"
|
||||||
retain: true
|
retain: true
|
||||||
- lambda: 'id(ramp_switch_target_on) = false;'
|
- lambda: "id(ramp_switch_target_on) = false;"
|
||||||
- script.stop: max_on_watchdog
|
- script.stop: max_on_watchdog
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(last_brightness_pct) = 0.0f;
|
id(last_brightness_pct) = 0.0f;
|
||||||
@@ -700,9 +699,9 @@ number:
|
|||||||
set_action:
|
set_action:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return x <= 0.0f;'
|
lambda: "return x <= 0.0f;"
|
||||||
then:
|
then:
|
||||||
- lambda: 'id(suppress_slider_sync) = true;'
|
- lambda: "id(suppress_slider_sync) = true;"
|
||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
@@ -714,7 +713,7 @@ number:
|
|||||||
id(last_brightness_pct) = 0.0f;
|
id(last_brightness_pct) = 0.0f;
|
||||||
id(last_set_pos) = 0;
|
id(last_set_pos) = 0;
|
||||||
- delay: 400ms
|
- delay: 400ms
|
||||||
- lambda: 'id(suppress_slider_sync) = false;'
|
- lambda: "id(suppress_slider_sync) = false;"
|
||||||
else:
|
else:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(suppress_slider_sync) = true;
|
id(suppress_slider_sync) = true;
|
||||||
@@ -745,7 +744,7 @@ number:
|
|||||||
if (out_pct > maxp) out_pct = maxp;
|
if (out_pct > maxp) out_pct = maxp;
|
||||||
id(last_brightness_pct) = out_pct;
|
id(last_brightness_pct) = out_pct;
|
||||||
- delay: 400ms
|
- delay: 400ms
|
||||||
- lambda: 'id(suppress_slider_sync) = false;'
|
- lambda: "id(suppress_slider_sync) = false;"
|
||||||
|
|
||||||
- platform: template
|
- platform: template
|
||||||
id: cfg_max_on_hours
|
id: cfg_max_on_hours
|
||||||
@@ -768,12 +767,12 @@ number:
|
|||||||
id(cfg_max_on_hours).publish_state((float) hrs);
|
id(cfg_max_on_hours).publish_state((float) hrs);
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(mosfet_leds).current_values.is_on();'
|
lambda: "return id(mosfet_leds).current_values.is_on();"
|
||||||
then:
|
then:
|
||||||
- script.stop: max_on_watchdog
|
- script.stop: max_on_watchdog
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(max_on_hours) > 0;'
|
lambda: "return id(max_on_hours) > 0;"
|
||||||
then:
|
then:
|
||||||
- script.execute: max_on_watchdog
|
- script.execute: max_on_watchdog
|
||||||
|
|
||||||
@@ -785,7 +784,7 @@ script:
|
|||||||
- id: ramp_on_script
|
- id: ramp_on_script
|
||||||
mode: restart
|
mode: restart
|
||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: "id(is_ramping) = true;"
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -796,11 +795,11 @@ script:
|
|||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda "return id(min_brightness_pct) / 100.0f;"
|
||||||
transition_length: 80ms
|
transition_length: 80ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(max_brightness_pct) / 100.0f;'
|
brightness: !lambda "return id(max_brightness_pct) / 100.0f;"
|
||||||
transition_length: !lambda |-
|
transition_length: !lambda |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
const float floor = id(min_brightness_pct) / 100.0f;
|
const float floor = id(min_brightness_pct) / 100.0f;
|
||||||
@@ -820,7 +819,7 @@ script:
|
|||||||
if (frac > 1.0f) frac = 1.0f;
|
if (frac > 1.0f) frac = 1.0f;
|
||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda "return (uint32_t) id(last_ramp_ms);"
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -832,7 +831,7 @@ script:
|
|||||||
- id: ramp_to_target_script
|
- id: ramp_to_target_script
|
||||||
mode: restart
|
mode: restart
|
||||||
then:
|
then:
|
||||||
- lambda: 'id(is_ramping) = true;'
|
- lambda: "id(is_ramping) = true;"
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
@@ -843,7 +842,7 @@ script:
|
|||||||
then:
|
then:
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda "return id(min_brightness_pct) / 100.0f;"
|
||||||
transition_length: 80ms
|
transition_length: 80ms
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
@@ -873,7 +872,7 @@ script:
|
|||||||
if (frac > 1.0f) frac = 1.0f;
|
if (frac > 1.0f) frac = 1.0f;
|
||||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda "return (uint32_t) id(last_ramp_ms);"
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(is_ramping) = false;
|
id(is_ramping) = false;
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
@@ -891,7 +890,7 @@ script:
|
|||||||
- script.stop: ramp_on_script
|
- script.stop: ramp_on_script
|
||||||
- light.turn_on:
|
- light.turn_on:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
brightness: !lambda "return id(min_brightness_pct) / 100.0f;"
|
||||||
transition_length: !lambda |-
|
transition_length: !lambda |-
|
||||||
const auto &cv = id(mosfet_leds).current_values;
|
const auto &cv = id(mosfet_leds).current_values;
|
||||||
const float floor = id(min_brightness_pct) / 100.0f;
|
const float floor = id(min_brightness_pct) / 100.0f;
|
||||||
@@ -904,7 +903,7 @@ script:
|
|||||||
if (frac > 1.0f) frac = 1.0f;
|
if (frac > 1.0f) frac = 1.0f;
|
||||||
id(last_ramp_ms) = (int) (id(ramp_down_ms) * frac);
|
id(last_ramp_ms) = (int) (id(ramp_down_ms) * frac);
|
||||||
return (uint32_t) id(last_ramp_ms);
|
return (uint32_t) id(last_ramp_ms);
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda "return (uint32_t) id(last_ramp_ms);"
|
||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 150ms
|
transition_length: 150ms
|
||||||
@@ -921,12 +920,12 @@ script:
|
|||||||
then:
|
then:
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(max_on_hours) > 0;'
|
lambda: "return id(max_on_hours) > 0;"
|
||||||
then:
|
then:
|
||||||
- delay: !lambda 'return (uint32_t) (id(max_on_hours) * 3600000UL);'
|
- delay: !lambda "return (uint32_t) (id(max_on_hours) * 3600000UL);"
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(mosfet_leds).current_values.is_on();'
|
lambda: "return id(mosfet_leds).current_values.is_on();"
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(ramp_switch_target_on) = false;
|
id(ramp_switch_target_on) = false;
|
||||||
@@ -950,17 +949,17 @@ script:
|
|||||||
|
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
lambda: 'return id(restore_target_pct) > 0.5f;'
|
lambda: "return id(restore_target_pct) > 0.5f;"
|
||||||
then:
|
then:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
id(ramp_switch_target_on) = true;
|
id(ramp_switch_target_on) = true;
|
||||||
id(suppress_slider_sync) = true;
|
id(suppress_slider_sync) = true;
|
||||||
- script.stop: ramp_off_script
|
- script.stop: ramp_off_script
|
||||||
- script.execute: ramp_to_target_script
|
- script.execute: ramp_to_target_script
|
||||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
- delay: !lambda "return (uint32_t) id(last_ramp_ms);"
|
||||||
- lambda: 'id(suppress_slider_sync) = false;'
|
- lambda: "id(suppress_slider_sync) = false;"
|
||||||
else:
|
else:
|
||||||
- lambda: 'id(ramp_switch_target_on) = false;'
|
- lambda: "id(ramp_switch_target_on) = false;"
|
||||||
- light.turn_off:
|
- light.turn_off:
|
||||||
id: mosfet_leds
|
id: mosfet_leds
|
||||||
transition_length: 0s
|
transition_length: 0s
|
||||||
Reference in New Issue
Block a user