Edit esp-entrancebathrmlights.yaml

This commit is contained in:
ESPHome Device Builder
2026-06-27 23:57:17 +12:00
parent dc827a3228
commit 9342616e33
+66 -62
View File
@@ -6,7 +6,8 @@
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-entrancebathrmlights.yaml # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-entrancebathrmlights.yaml
#:########################################################################################:# #:########################################################################################:#
# VERSIONS: # VERSIONS:
# V4.0 2026-06-27 Added extract fan timer enable switch and minute countdown sensor # V4.1 2026-06-27 Changed fan timer back to MM:SS with 1 second countdown and 00:00 when fan is off
# V4.0 2026-06-27 Added extract fan timer enable switch and countdown sensor
# V3.9 2026-03-11 Updated yaml to zorruno layout V1.1 # V3.9 2026-03-11 Updated yaml to zorruno layout V1.1
# V3.8 2026-02-25 Updated yaml to zorruno layout V1.1 # V3.8 2026-02-25 Updated yaml to zorruno layout V1.1
# V3.7 2025-09-34 Upload to this bathroom (as noted in original header) # V3.7 2025-09-34 Upload to this bathroom (as noted in original header)
@@ -30,8 +31,8 @@
# - Countdown starts when the light turns OFF while the fan is ON. # - Countdown starts when the light turns OFF while the fan is ON.
# - Countdown also starts when the fan turns ON while the light is already OFF. # - Countdown also starts when the fan turns ON while the light is already OFF.
# - Countdown is cancelled/reset if the light turns ON or the fan turns OFF manually. # - Countdown is cancelled/reset if the light turns ON or the fan turns OFF manually.
# - The timer remaining sensor shows whole minutes remaining. # - The timer remaining sensor shows MM:SS while counting down.
# - When idle, the timer remaining sensor sits at the configured timer duration. # - When the fan is OFF, the timer remaining sensor shows 00:00.
#:########################################################################################:# #:########################################################################################:#
# OFFLINE NOTES: # OFFLINE NOTES:
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE # a) Home Assistant OFFLINE, but Network and MQTT ONLINE
@@ -61,7 +62,7 @@ substitutions:
# Project Naming # Project Naming
project_name: "Zemismart Technologies.KS-811 Double" project_name: "Zemismart Technologies.KS-811 Double"
project_version: "v4.0" project_version: "v4.1"
# Passwords & Secrets # Passwords & Secrets
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
@@ -118,7 +119,7 @@ packages:
#### DIAGNOSTICS Sensors #### #### DIAGNOSTICS Sensors ####
diag_basic: !include common/include_basic_diag_sensors.yaml diag_basic: !include common/include_basic_diag_sensors.yaml
#diag_more: !include common/include_more_diag_sensors.yaml diag_more: !include common/include_more_diag_sensors.yaml
#diag_debug: !include common/include_debug_diag_sensors.yaml #diag_debug: !include common/include_debug_diag_sensors.yaml
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml #diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
@@ -173,7 +174,7 @@ globals:
restore_value: false restore_value: false
initial_value: "false" initial_value: "false"
- id: fan_timer_remaining_minutes - id: fan_timer_remaining_seconds
type: int type: int
restore_value: false restore_value: false
initial_value: "0" initial_value: "0"
@@ -238,24 +239,35 @@ switch:
- script.execute: fan_timer_evaluate - script.execute: fan_timer_evaluate
#:########################################################################################:# #:########################################################################################:#
# SENSORS # TEXT SENSORS
# https://esphome.io/components/sensor/ # https://esphome.io/components/text_sensor/
#:########################################################################################:# #:########################################################################################:#
sensor: text_sensor:
- platform: template - platform: template
name: "Fan Timer Remaining Minutes" name: "Fan Timer Remaining"
id: fan_timer_remaining_minutes_sensor id: fan_timer_remaining_text
icon: "mdi:timer-outline" icon: "mdi:timer-outline"
unit_of_measurement: "min" update_interval: 1s
accuracy_decimals: 0
device_class: duration
update_interval: 60s
lambda: |- lambda: |-
if (id(fan_timer_counting_down)) { int seconds = 0;
return id(fan_timer_remaining_minutes);
if (id(Relay_2).state && id(fan_timer_counting_down)) {
seconds = id(fan_timer_remaining_seconds);
} else {
seconds = 0;
} }
return ${fan_timer_duration_minutes}; if (seconds < 0) {
seconds = 0;
}
int mins = seconds / 60;
int secs = seconds % 60;
char buffer[8];
snprintf(buffer, sizeof(buffer), "%02d:%02d", mins, secs);
return std::string(buffer);
#:########################################################################################:# #:########################################################################################:#
# SCRIPTS # SCRIPTS
@@ -265,11 +277,10 @@ script:
- id: fan_timer_cancel - id: fan_timer_cancel
mode: restart mode: restart
then: then:
- script.stop: fan_timer_countdown
- lambda: |- - lambda: |-
id(fan_timer_counting_down) = false; id(fan_timer_counting_down) = false;
id(fan_timer_remaining_minutes) = 0; id(fan_timer_remaining_seconds) = 0;
- component.update: fan_timer_remaining_minutes_sensor - component.update: fan_timer_remaining_text
- id: fan_timer_evaluate - id: fan_timer_evaluate
mode: restart mode: restart
@@ -279,52 +290,45 @@ script:
lambda: |- lambda: |-
return id(fan_timer_enabled).state && !id(Relay_1).state && id(Relay_2).state; return id(fan_timer_enabled).state && !id(Relay_1).state && id(Relay_2).state;
then: then:
- script.execute: fan_timer_countdown - lambda: |-
id(fan_timer_remaining_seconds) = ${fan_timer_duration_minutes} * 60;
id(fan_timer_counting_down) = true;
- component.update: fan_timer_remaining_text
else: else:
- script.execute: fan_timer_cancel - script.execute: fan_timer_cancel
- id: fan_timer_countdown #:########################################################################################:#
mode: restart # INTERVALS
# https://esphome.io/components/interval.html
#:########################################################################################:#
interval:
- interval: 1s
then: then:
- lambda: |-
id(fan_timer_counting_down) = true;
id(fan_timer_remaining_minutes) = ${fan_timer_duration_minutes};
- component.update: fan_timer_remaining_minutes_sensor
- while:
condition:
lambda: |-
return id(fan_timer_counting_down)
&& id(fan_timer_enabled).state
&& !id(Relay_1).state
&& id(Relay_2).state
&& id(fan_timer_remaining_minutes) > 0;
then:
- delay: 60s
- if:
condition:
lambda: |-
return id(fan_timer_counting_down)
&& id(fan_timer_enabled).state
&& !id(Relay_1).state
&& id(Relay_2).state
&& id(fan_timer_remaining_minutes) > 0;
then:
- lambda: |-
id(fan_timer_remaining_minutes) -= 1;
- component.update: fan_timer_remaining_minutes_sensor
- if: - if:
condition: condition:
lambda: |- lambda: |-
return id(fan_timer_counting_down) return id(fan_timer_counting_down);
&& id(fan_timer_enabled).state
&& !id(Relay_1).state
&& id(Relay_2).state
&& id(fan_timer_remaining_minutes) <= 0;
then: then:
- lambda: |- - if:
id(fan_timer_counting_down) = false; condition:
id(fan_timer_remaining_minutes) = 0; lambda: |-
- component.update: fan_timer_remaining_minutes_sensor return id(fan_timer_enabled).state && !id(Relay_1).state && id(Relay_2).state;
- switch.turn_off: Relay_2 then:
- lambda: |-
if (id(fan_timer_remaining_seconds) > 0) {
id(fan_timer_remaining_seconds) -= 1;
}
- component.update: fan_timer_remaining_text
- if:
condition:
lambda: |-
return id(fan_timer_remaining_seconds) <= 0;
then:
- lambda: |-
id(fan_timer_counting_down) = false;
id(fan_timer_remaining_seconds) = 0;
- component.update: fan_timer_remaining_text
- switch.turn_off: Relay_2
else:
- script.execute: fan_timer_cancel