esphome lounge switches and scene control
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"pid": 67, "version": 1, "ha_version": "2025.10.1", "start_ts": 1759647901.614362}
|
||||
@@ -11,20 +11,20 @@
|
||||
state: "on"
|
||||
sequence:
|
||||
- service: switch.turn_on
|
||||
entity_id: switch.tasmo_ks811d_5613_lounge_4b
|
||||
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
|
||||
default:
|
||||
- service: switch.turn_off
|
||||
entity_id: switch.tasmo_ks811d_5613_lounge_4b
|
||||
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
|
||||
- id: "Two_Way_Lights_-_Garage_Corridor_-_2"
|
||||
alias: "Two Way Lights - Garage Corridor - 2"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: switch.tasmo_ks811d_5613_lounge_4b
|
||||
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
|
||||
action:
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: switch.tasmo_ks811d_5613_lounge_4b
|
||||
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
|
||||
state: "on"
|
||||
sequence:
|
||||
- service: switch.turn_on
|
||||
@@ -46,7 +46,7 @@
|
||||
state: "on"
|
||||
sequence:
|
||||
- service: switch.turn_on
|
||||
entity_id: switch.tasmo_sbas_0407_garagelight
|
||||
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
|
||||
default:
|
||||
- service: switch.turn_off
|
||||
entity_id: switch.tasmo_sbas_0407_garagelight
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
substitutions:
|
||||
mqtt_command_main_topic: !secret mqtt_command_main_topic
|
||||
mqtt_status_main_topic: !secret mqtt_status_main_topic
|
||||
|
||||
# MQTT REMOTE Controls
|
||||
mqtt_remote1_device_name: "3dprinter-power"
|
||||
mqtt_remote1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote1_device_name}" # Topic we will use to command this locally without HA
|
||||
mqtt_remote1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote1_device_name}" # Topic we will use to view status locally without HA
|
||||
@@ -115,7 +115,6 @@ button:
|
||||
# SCRIPTS
|
||||
##########################################################################################
|
||||
script:
|
||||
# Classify last reset exactly once per boot
|
||||
- id: classify_reset_once
|
||||
mode: restart
|
||||
then:
|
||||
@@ -123,40 +122,60 @@ script:
|
||||
// Guard: only run once per boot
|
||||
if (id(reset_classified_this_boot)) return;
|
||||
|
||||
// Read raw reason string (examples: "Power on", "External System",
|
||||
// "Software/System restart", "Fatal exception:29", "WDT reset")
|
||||
String reason = ESP.getResetReason();
|
||||
// Build a human-readable reason string that's valid on both ESP8266 and ESP32
|
||||
std::string reason;
|
||||
int cat = 0; // 1=power, 2=software, 3=crash
|
||||
|
||||
// Category: 1=power, 2=software, 3=crash
|
||||
int cat = 0;
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
// ESP8266: use Arduino core helper, returns Arduino String
|
||||
reason = std::string(ESP.getResetReason().c_str());
|
||||
|
||||
// Crash has priority if phrases appear (rare but be explicit)
|
||||
if (reason.indexOf("Watchdog") >= 0 || reason.indexOf("WDT") >= 0 ||
|
||||
reason.indexOf("Exception") >= 0 || reason.indexOf("exception") >= 0) {
|
||||
cat = 3; // crash
|
||||
}
|
||||
// Software/System restart (HA/API/OTA initiated)
|
||||
else if (reason.indexOf("Software") >= 0 || reason.indexOf("System") >= 0) {
|
||||
cat = 2; // software
|
||||
}
|
||||
// Power-like causes (power-on, external reset pin/button, deep sleep wake)
|
||||
else if (reason.indexOf("Power") >= 0 || reason.indexOf("External") >= 0 ||
|
||||
reason.indexOf("Deep") >= 0) {
|
||||
cat = 1; // power
|
||||
}
|
||||
// Anything else -> crash bucket
|
||||
else {
|
||||
// Classify (string match like your original)
|
||||
if (reason.find("Watchdog") != std::string::npos ||
|
||||
reason.find("WDT") != std::string::npos ||
|
||||
reason.find("Exception")!= std::string::npos ||
|
||||
reason.find("exception")!= std::string::npos) {
|
||||
cat = 3;
|
||||
} else if (reason.find("Software") != std::string::npos ||
|
||||
reason.find("System") != std::string::npos) {
|
||||
cat = 2;
|
||||
} else if (reason.find("Power") != std::string::npos ||
|
||||
reason.find("External") != std::string::npos ||
|
||||
reason.find("Deep") != std::string::npos) {
|
||||
cat = 1;
|
||||
} else {
|
||||
cat = 3;
|
||||
}
|
||||
|
||||
#elif defined(ARDUINO_ARCH_ESP32)
|
||||
// ESP32: use IDF enum and map to text + categories directly
|
||||
esp_reset_reason_t r = esp_reset_reason();
|
||||
switch (r) {
|
||||
case ESP_RST_POWERON: reason = "Power on"; cat = 1; break;
|
||||
case ESP_RST_EXT: reason = "External reset"; cat = 1; break; // reset pin/button
|
||||
case ESP_RST_SW: reason = "Software reset"; cat = 2; break; // OTA/API/HA/etc.
|
||||
case ESP_RST_PANIC: reason = "Panic/exception"; cat = 3; break;
|
||||
case ESP_RST_INT_WDT: reason = "Interrupt WDT"; cat = 3; break;
|
||||
case ESP_RST_TASK_WDT: reason = "Task WDT"; cat = 3; break;
|
||||
case ESP_RST_WDT: reason = "Other WDT"; cat = 3; break;
|
||||
case ESP_RST_DEEPSLEEP: reason = "Deep sleep wake"; cat = 1; break;
|
||||
case ESP_RST_BROWNOUT: reason = "Brownout"; cat = 1; break; // power-ish
|
||||
case ESP_RST_SDIO: reason = "SDIO reset"; cat = 3; break;
|
||||
default: reason = "Unknown reset reason"; cat = 3; break;
|
||||
}
|
||||
#else
|
||||
// Fallback for any other arch (very unlikely in your setup)
|
||||
reason = "Unknown platform reset";
|
||||
cat = 3;
|
||||
#endif
|
||||
|
||||
// Increment counters
|
||||
if (cat == 1) id(power_reset_count) += 1;
|
||||
if (cat == 2) id(software_reset_count) += 1;
|
||||
if (cat == 3) id(crash_reset_count) += 1;
|
||||
|
||||
// Publish reason text now
|
||||
// Publish reason and mark done
|
||||
id(last_reset_reason_txt).publish_state(reason.c_str());
|
||||
|
||||
// Mark done for this boot
|
||||
id(reset_classified_this_boot) = true;
|
||||
|
||||
# Publish the three counters (kept separate so we can reuse)
|
||||
@@ -181,3 +200,4 @@ interval:
|
||||
- script.execute: classify_reset_once
|
||||
- script.execute: publish_reset_status
|
||||
# On later passes, the guard prevents re-counting and this block does nothing.
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ substitutions:
|
||||
#############################################
|
||||
# MQTT Monitoring
|
||||
# https://esphome.io/components/mqtt.html?highlight=mqtt
|
||||
# MUST also have api enabled if you enable MQTT
|
||||
#############################################
|
||||
mqtt:
|
||||
broker: ${mqtt_server}
|
||||
|
||||
@@ -72,6 +72,7 @@ packages:
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
|
||||
@@ -42,6 +42,46 @@ substitutions:
|
||||
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
|
||||
|
||||
##########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
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
|
||||
@@ -79,37 +119,6 @@ logger:
|
||||
ota:
|
||||
- platform: web_server # Uncomment if you want to be able to do OTA with the web interface
|
||||
|
||||
##########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
common_api: !include
|
||||
#file: common/api_common_noencryption.yaml
|
||||
file: common/api_common.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
common_webportal: !include
|
||||
file: common/webportal_common.yaml
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
#common_sntp: !include
|
||||
# file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common_lite.yaml
|
||||
#file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
##########################################################################################
|
||||
# MQTT COMMANDS
|
||||
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||
|
||||
@@ -66,29 +66,38 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -70,29 +70,38 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -53,30 +53,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -65,30 +65,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
@@ -103,16 +114,10 @@ esphome:
|
||||
priority : -100
|
||||
then:
|
||||
- delay: 200ms
|
||||
#- fan.toggle: ifan02_fan
|
||||
#- fan.toggle: ifan02_fan
|
||||
#- delay: 200ms
|
||||
#- light.toggle: ifan02_light
|
||||
#- delay: 1ms
|
||||
#- light.toggle: ifan02_light
|
||||
#- delay: 1s
|
||||
- mqtt.publish:
|
||||
topic: "${mqtt_local_status_topic}/speed/state"
|
||||
payload: !lambda 'return to_string(id(speed_value));'
|
||||
|
||||
# platformio_options:
|
||||
# build_flags:
|
||||
# - "-Os" # optimize for size
|
||||
|
||||
@@ -69,30 +69,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -66,30 +66,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -106,8 +106,8 @@ packages:
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
#file: common/api_common.yaml
|
||||
file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
@@ -124,9 +124,9 @@ packages:
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
#diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome CORE CONFIGURATION
|
||||
@@ -179,6 +179,9 @@ esphome:
|
||||
# Boot complete: allow OFF handlers again
|
||||
- lambda: 'id(booting) = false;'
|
||||
|
||||
# NEW: force indicator OFF after boot logic
|
||||
- output.turn_off: green_led_out
|
||||
|
||||
# Only if you want to play with build flags...
|
||||
# platformio_options:
|
||||
# build_unflags:
|
||||
@@ -200,10 +203,10 @@ esp8266:
|
||||
restore_from_flash: true # restore some values on reboot
|
||||
|
||||
mdns:
|
||||
disabled: false # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
disabled: true # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 5sec # enough time to update values for reboots, but not enough to wear flash
|
||||
flash_write_interval: 2min # enough time to update values for reboots, but not enough to wear flash
|
||||
|
||||
##########################################################################################
|
||||
# GLOBAL VARIABLES
|
||||
@@ -269,11 +272,6 @@ globals:
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: '0'
|
||||
# last non-zero actual 0..100 used, for stable "Restore Brightness"
|
||||
- id: last_nonzero_brightness_pct
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: '0.0'
|
||||
# target for "Restore Brightness" scripted ramp
|
||||
- id: restore_target_pct
|
||||
type: float
|
||||
@@ -284,17 +282,12 @@ globals:
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
# volatile (non-persistent) last non-zero brightness during ramps
|
||||
- id: last_nonzero_tmp
|
||||
type: float
|
||||
restore_value: false
|
||||
initial_value: '0.0'
|
||||
# guards OFF persistence during startup caused by restore_mode: ALWAYS_OFF
|
||||
- id: booting
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'true'
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
- id: ramping_for_off
|
||||
type: bool
|
||||
restore_value: false
|
||||
@@ -396,8 +389,6 @@ button:
|
||||
# Stop any pending scripts (and their delayed actions)
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_up
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
// We are no longer ramping (up or down)
|
||||
@@ -414,14 +405,14 @@ button:
|
||||
call.perform();
|
||||
}
|
||||
|
||||
// Persist the exact frozen level so "Restore Brightness" survives a reboot
|
||||
// Persist the exact frozen level so restore survives a reboot
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct;
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# SELECT COMPONENT
|
||||
# https://esphome.io/components/select/index.html
|
||||
@@ -462,8 +453,8 @@ binary_sensor:
|
||||
pullup: true
|
||||
inverted: true
|
||||
filters:
|
||||
- delayed_on: 20ms
|
||||
- delayed_off: 20ms
|
||||
- delayed_on: 30ms
|
||||
- delayed_off: 30ms
|
||||
on_press:
|
||||
- if:
|
||||
condition:
|
||||
@@ -494,29 +485,16 @@ sensor:
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:percent
|
||||
accuracy_decimals: 0
|
||||
update_interval: 250ms # consider 200ms if you want fewer updates
|
||||
update_interval: 1s # consider 200ms if you want fewer updates
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
const auto &cv_now = id(mosfet_leds).current_values;
|
||||
|
||||
// Only persist exact last brightness while actually ON,
|
||||
// and not during the OFF ramp's brief floor-kick.
|
||||
if (cv_now.is_on()) {
|
||||
if (x > 0.5f) {
|
||||
if (!id(is_ramping)) id(last_nonzero_brightness_pct) = x;
|
||||
id(last_nonzero_tmp) = x;
|
||||
}
|
||||
} else {
|
||||
if (x > 0.5f) id(last_nonzero_tmp) = x;
|
||||
}
|
||||
|
||||
// If not suppressing sync, update the 0..100 slider only when its INT changes
|
||||
if (!id(suppress_slider_sync)) {
|
||||
float actual = x;
|
||||
float actual = x; // x is current Output (%)
|
||||
float minp = (float) id(min_brightness_pct);
|
||||
float maxp = (float) id(max_brightness_pct);
|
||||
if (maxp <= minp) maxp = minp + 1.0f;
|
||||
@@ -530,13 +508,14 @@ sensor:
|
||||
id(led_output_set_pct).publish_state(pos_i);
|
||||
}
|
||||
}
|
||||
|
||||
- platform: template
|
||||
id: mosfet_output_pwm_pct
|
||||
name: "${friendly_name} Output PWM (%)"
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:square-wave
|
||||
accuracy_decimals: 1
|
||||
update_interval: 250ms
|
||||
update_interval: 1s
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
if (!cv.is_on()) return 0.0f;
|
||||
@@ -547,6 +526,7 @@ sensor:
|
||||
if (pwm > 1.0f) pwm = 1.0f;
|
||||
return pwm * 100.0f;
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# OUTPUT COMPONENT
|
||||
# https://esphome.io/components/light/index.html
|
||||
@@ -742,10 +722,6 @@ number:
|
||||
float out_pct = minp + (pos * (maxp - minp) / 100.0f);
|
||||
if (out_pct > maxp) out_pct = maxp;
|
||||
id(last_brightness_pct) = out_pct; // persist exact target now
|
||||
if (out_pct > 0.5f) {
|
||||
id(last_nonzero_brightness_pct) = out_pct;
|
||||
id(last_nonzero_tmp) = out_pct;
|
||||
}
|
||||
- delay: 400ms
|
||||
- lambda: 'id(suppress_slider_sync) = false;'
|
||||
|
||||
@@ -785,43 +761,14 @@ number:
|
||||
# Scripts can be executed nearly anywhere in your device configuration with a single call.
|
||||
##########################################################################################
|
||||
script:
|
||||
# Blink pattern while ramping UP: quick double-blink, pause, repeat
|
||||
- id: led_flash_up
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 400ms
|
||||
# Blink pattern while ramping DOWN: steady slow blink
|
||||
- id: led_flash_down
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 250ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 250ms
|
||||
|
||||
# Script: ramp up from current level. Obey global max.
|
||||
# Script: ramp up from current level. Obey global max. (LED ON while ramping)
|
||||
- id: ramp_on_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at at least the floor without a visible "pop".
|
||||
- if:
|
||||
condition:
|
||||
@@ -858,7 +805,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -866,17 +812,15 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp to a specific target (Restore Brightness path)
|
||||
# Script: ramp to a specific target (Restore Brightness path). (LED ON while ramping)
|
||||
- id: ramp_to_target_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at the floor cleanly.
|
||||
- if:
|
||||
condition:
|
||||
@@ -919,7 +863,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -927,10 +870,10 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF. (LED ON while ramping)
|
||||
- id: ramp_off_script
|
||||
mode: restart
|
||||
then:
|
||||
@@ -938,8 +881,7 @@ script:
|
||||
id(is_ramping) = true;
|
||||
id(ramping_for_off) = true;
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: led_flash_up
|
||||
- script.execute: led_flash_down
|
||||
- output.turn_on: green_led_out
|
||||
- light.turn_on:
|
||||
id: mosfet_leds
|
||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||
@@ -960,7 +902,6 @@ script:
|
||||
id: mosfet_leds
|
||||
transition_length: 150ms
|
||||
- delay: 150ms
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -1021,3 +962,4 @@ script:
|
||||
- light.turn_off:
|
||||
id: mosfet_leds
|
||||
transition_length: 0s
|
||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
||||
@@ -66,30 +66,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -65,30 +65,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -42,9 +42,10 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
|
||||
# Network and Wi-Fi
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
@@ -52,32 +53,30 @@ packages:
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
# Native API
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
#local_api_key: "${api_key}"
|
||||
local_api_key: "5dW+2PdmYb7ovzvt/tGPbLU6XfBHsQeeUgZ5/ImQFA8="
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
# # Web Portal
|
||||
# common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
# MQTT
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
# Time/SNTP
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
# Device Specific included packages
|
||||
# Athom Power Monitor Plug V2 (No Relay)
|
||||
|
||||
@@ -43,9 +43,10 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
|
||||
# Network and Wi-Fi
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
@@ -53,32 +54,30 @@ packages:
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
# Native API
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
#local_api_key: "${api_key}"
|
||||
local_api_key: "tZ/djAp4qiM0wYCgUa1amg+wK7KTF9xR8bUFCaeVskM="
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
# Web Portal
|
||||
common_webportal: !include
|
||||
file: common/webportal_common.yaml
|
||||
|
||||
# MQTT
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
# Time/SNTP
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
# Device Specific included packages
|
||||
# Athom Power Monitor Plug V2 (No Relay)
|
||||
|
||||
@@ -48,9 +48,10 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
|
||||
# Network and Wifi
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
@@ -58,30 +59,30 @@ packages:
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
# Network and Wifi
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
# # Web Portal
|
||||
# common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
# MQTT
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
# Time/SNMP
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
# Device Specific included packages
|
||||
# Athom Power Monitor Plug
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# - "Fade up to full": fade from floor to max on boot.
|
||||
# - "Restore Brightness": fade from floor to the last non-zero brightness on boot (should be no on/off blip/flash).
|
||||
# - "Remain Off": stays off on boot.
|
||||
# 9. The green LED flashes while fading (different patterns for up/down). The red LED follows the
|
||||
# 9. Green LED rule: ON while any ramp script is executing, otherwise OFF. The red LED follows the
|
||||
# output (it shares the MOSFET GPIO). (Obviously this depends on hardware)
|
||||
# 10. Fade timing scales with the configured values (proportionally when starting mid-brightness).
|
||||
# 11. Exposed in Home Assistant/MQTT:
|
||||
@@ -94,7 +94,7 @@ substitutions:
|
||||
minimum_led_output: "1" # % If at this value or below, we'll 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: "1000hz" # PWM output Frequency. High enough to avoid audible/visible artifacts
|
||||
pwm_frequency: "1000 hz" # PWM output Frequency. High enough to avoid audible/visible artifacts
|
||||
|
||||
# Device Specific GPIO (so we can easily update for other devices)
|
||||
device_status_led: GPIO02
|
||||
@@ -190,6 +190,9 @@ esphome:
|
||||
# Boot complete: allow OFF handlers again
|
||||
- lambda: 'id(booting) = false;'
|
||||
|
||||
# NEW: force indicator OFF after boot logic
|
||||
- output.turn_off: green_led_out
|
||||
|
||||
# Only if you want to play with build flags...
|
||||
# platformio_options:
|
||||
# build_unflags:
|
||||
@@ -211,10 +214,10 @@ esp8266:
|
||||
restore_from_flash: true # restore some values on reboot
|
||||
|
||||
mdns:
|
||||
disabled: false # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
disabled: true # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 5sec # enough time to update values for reboots, but not enough to wear flash
|
||||
flash_write_interval: 2min # enough time to update values for reboots, but not enough to wear flash
|
||||
|
||||
##########################################################################################
|
||||
# GLOBAL VARIABLES
|
||||
@@ -280,11 +283,6 @@ globals:
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: '0'
|
||||
# last non-zero actual 0..100 used, for stable "Restore Brightness"
|
||||
- id: last_nonzero_brightness_pct
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: '0.0'
|
||||
# target for "Restore Brightness" scripted ramp
|
||||
- id: restore_target_pct
|
||||
type: float
|
||||
@@ -295,17 +293,12 @@ globals:
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
# volatile (non-persistent) last non-zero brightness during ramps
|
||||
- id: last_nonzero_tmp
|
||||
type: float
|
||||
restore_value: false
|
||||
initial_value: '0.0'
|
||||
# guards OFF persistence during startup caused by restore_mode: ALWAYS_OFF
|
||||
- id: booting
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'true'
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
- id: ramping_for_off
|
||||
type: bool
|
||||
restore_value: false
|
||||
@@ -407,8 +400,6 @@ button:
|
||||
# Stop any pending scripts (and their delayed actions)
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_up
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
// We are no longer ramping (up or down)
|
||||
@@ -425,14 +416,14 @@ button:
|
||||
call.perform();
|
||||
}
|
||||
|
||||
// Persist the exact frozen level so "Restore Brightness" survives a reboot
|
||||
// Persist the exact frozen level so restore survives a reboot
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct;
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# SELECT COMPONENT
|
||||
# https://esphome.io/components/select/index.html
|
||||
@@ -473,8 +464,8 @@ binary_sensor:
|
||||
pullup: true
|
||||
inverted: true
|
||||
filters:
|
||||
- delayed_on: 20ms
|
||||
- delayed_off: 20ms
|
||||
- delayed_on: 30ms
|
||||
- delayed_off: 30ms
|
||||
on_press:
|
||||
- if:
|
||||
condition:
|
||||
@@ -505,29 +496,16 @@ sensor:
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:percent
|
||||
accuracy_decimals: 0
|
||||
update_interval: 250ms # consider 200ms if you want fewer updates
|
||||
update_interval: 1s # consider 200ms if you want fewer updates
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
const auto &cv_now = id(mosfet_leds).current_values;
|
||||
|
||||
// Only persist exact last brightness while actually ON,
|
||||
// and not during the OFF ramp's brief floor-kick.
|
||||
if (cv_now.is_on()) {
|
||||
if (x > 0.5f) {
|
||||
if (!id(is_ramping)) id(last_nonzero_brightness_pct) = x;
|
||||
id(last_nonzero_tmp) = x;
|
||||
}
|
||||
} else {
|
||||
if (x > 0.5f) id(last_nonzero_tmp) = x;
|
||||
}
|
||||
|
||||
// If not suppressing sync, update the 0..100 slider only when its INT changes
|
||||
if (!id(suppress_slider_sync)) {
|
||||
float actual = x;
|
||||
float actual = x; // x is current Output (%)
|
||||
float minp = (float) id(min_brightness_pct);
|
||||
float maxp = (float) id(max_brightness_pct);
|
||||
if (maxp <= minp) maxp = minp + 1.0f;
|
||||
@@ -541,13 +519,14 @@ sensor:
|
||||
id(led_output_set_pct).publish_state(pos_i);
|
||||
}
|
||||
}
|
||||
|
||||
- platform: template
|
||||
id: mosfet_output_pwm_pct
|
||||
name: "${friendly_name} Output PWM (%)"
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:square-wave
|
||||
accuracy_decimals: 1
|
||||
update_interval: 250ms
|
||||
update_interval: 1s
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
if (!cv.is_on()) return 0.0f;
|
||||
@@ -558,6 +537,7 @@ sensor:
|
||||
if (pwm > 1.0f) pwm = 1.0f;
|
||||
return pwm * 100.0f;
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# OUTPUT COMPONENT
|
||||
# https://esphome.io/components/light/index.html
|
||||
@@ -753,10 +733,6 @@ number:
|
||||
float out_pct = minp + (pos * (maxp - minp) / 100.0f);
|
||||
if (out_pct > maxp) out_pct = maxp;
|
||||
id(last_brightness_pct) = out_pct; // persist exact target now
|
||||
if (out_pct > 0.5f) {
|
||||
id(last_nonzero_brightness_pct) = out_pct;
|
||||
id(last_nonzero_tmp) = out_pct;
|
||||
}
|
||||
- delay: 400ms
|
||||
- lambda: 'id(suppress_slider_sync) = false;'
|
||||
|
||||
@@ -796,43 +772,14 @@ number:
|
||||
# Scripts can be executed nearly anywhere in your device configuration with a single call.
|
||||
##########################################################################################
|
||||
script:
|
||||
# Blink pattern while ramping UP: quick double-blink, pause, repeat
|
||||
- id: led_flash_up
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 400ms
|
||||
# Blink pattern while ramping DOWN: steady slow blink
|
||||
- id: led_flash_down
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 250ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 250ms
|
||||
|
||||
# Script: ramp up from current level. Obey global max.
|
||||
# Script: ramp up from current level. Obey global max. (LED ON while ramping)
|
||||
- id: ramp_on_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at at least the floor without a visible "pop".
|
||||
- if:
|
||||
condition:
|
||||
@@ -869,7 +816,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -877,17 +823,15 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp to a specific target (Restore Brightness path)
|
||||
# Script: ramp to a specific target (Restore Brightness path). (LED ON while ramping)
|
||||
- id: ramp_to_target_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at the floor cleanly.
|
||||
- if:
|
||||
condition:
|
||||
@@ -930,7 +874,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -938,10 +881,10 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF. (LED ON while ramping)
|
||||
- id: ramp_off_script
|
||||
mode: restart
|
||||
then:
|
||||
@@ -949,8 +892,7 @@ script:
|
||||
id(is_ramping) = true;
|
||||
id(ramping_for_off) = true;
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: led_flash_up
|
||||
- script.execute: led_flash_down
|
||||
- output.turn_on: green_led_out
|
||||
- light.turn_on:
|
||||
id: mosfet_leds
|
||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||
@@ -971,7 +913,6 @@ script:
|
||||
id: mosfet_leds
|
||||
transition_length: 150ms
|
||||
- delay: 150ms
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -1032,3 +973,5 @@ script:
|
||||
- light.turn_off:
|
||||
id: mosfet_leds
|
||||
transition_length: 0s
|
||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#############################################
|
||||
#############################################
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# DOWNSTAIRS BATHROOM MAIN LIGHTSWITCH
|
||||
# V2.0 2025-06-05 YAML Tidyups
|
||||
# V1.0 2025-02-14 Initial Version
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# Zemismart KS-811 Triple push button
|
||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||
#
|
||||
# NOTES
|
||||
# -
|
||||
#
|
||||
#############################################
|
||||
#############################################
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# 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-downstbathswitch"
|
||||
@@ -46,70 +46,81 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#############################################
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
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
|
||||
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#############################################
|
||||
##########################################################################################
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# 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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
#############################################
|
||||
##########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO2
|
||||
inverted: True
|
||||
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#############################################
|
||||
##########################################################################################
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
@@ -199,10 +210,10 @@ binary_sensor:
|
||||
else:
|
||||
- switch.turn_on: Relay_3
|
||||
|
||||
#############################################
|
||||
##########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
#############################################
|
||||
##########################################################################################
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "Relay 1: ${switch_1_name}"
|
||||
|
||||
@@ -82,30 +82,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -55,30 +55,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -42,30 +42,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -61,30 +61,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -56,29 +56,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -56,29 +56,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -55,30 +55,41 @@ substitutions:
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
# Comment some of these out where not needed, eg MQTT, Web portal, SNTP, General Sensors
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -31,29 +31,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -49,10 +49,6 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
##################################################
|
||||
# MANDATORY packages (won't compile without them!)
|
||||
##################################################
|
||||
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
@@ -61,10 +57,6 @@ packages:
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
##################################################
|
||||
# OPTIONAL packages (comment if you don't want them)
|
||||
##################################################
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
@@ -72,34 +64,22 @@ packages:
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include
|
||||
# file: common/sntp_common.yaml
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Lite Sensors ####
|
||||
# Option of everything, or a lite version
|
||||
common_lite_sensors: !include
|
||||
file: common/sensors_common_lite.yaml
|
||||
|
||||
#### DIAGNOSTICS General Sensors ####
|
||||
# Option of everything, or a lite version
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
|
||||
#### DEBUGGING Sensors ####
|
||||
# A count of various resets
|
||||
#common_resetcount_debugging: !include
|
||||
# file: common/resetcount_common.yaml
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -55,29 +55,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -55,29 +55,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -75,29 +75,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome CORE CONFIGURATION
|
||||
|
||||
@@ -35,29 +35,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -35,29 +35,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -58,10 +58,6 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
##################################################
|
||||
# MANDATORY packages (won't compile without them!)
|
||||
##################################################
|
||||
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
@@ -70,10 +66,6 @@ packages:
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
##################################################
|
||||
# OPTIONAL packages (comment if you don't want them)
|
||||
##################################################
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
@@ -88,14 +80,14 @@ packages:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
common_webportal: !include common/webportal_common.yaml
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_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
|
||||
|
||||
#########################################################################################
|
||||
|
||||
@@ -35,29 +35,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -35,29 +35,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -89,8 +89,16 @@ substitutions:
|
||||
min_output_2: "0.20f"
|
||||
min_output_3: "0.20f"
|
||||
min_output_4: "0.20f"
|
||||
min_output_5: "0.20f"
|
||||
min_output_6: "0.20f"
|
||||
min_output_5: "0.10f"
|
||||
min_output_6: "0.10f"
|
||||
|
||||
# Per-channel gamma correct
|
||||
gamma_output_1: "2.2"
|
||||
gamma_output_2: "2.2"
|
||||
gamma_output_3: "2.2"
|
||||
gamma_output_4: "1"
|
||||
gamma_output_5: "2.2"
|
||||
gamma_output_6: "2.2"
|
||||
|
||||
#########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
@@ -122,6 +130,7 @@ packages:
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
@@ -214,42 +223,42 @@ light:
|
||||
output: dmx_1
|
||||
id: light_test_1
|
||||
default_transition_length: 10s
|
||||
gamma_correct: 2.2
|
||||
gamma_correct: ${gamma_output_1}
|
||||
restore_mode: ALWAYS_ON
|
||||
- platform: monochromatic
|
||||
name: ${output_2_name}
|
||||
output: dmx_2
|
||||
id: light_test_2
|
||||
default_transition_length: 10s
|
||||
gamma_correct: 2.2
|
||||
gamma_correct: ${gamma_output_2}
|
||||
restore_mode: ALWAYS_ON
|
||||
- platform: monochromatic
|
||||
name: ${output_3_name}
|
||||
output: dmx_3
|
||||
id: light_test_3
|
||||
default_transition_length: 10s
|
||||
gamma_correct: 2.2
|
||||
gamma_correct: ${gamma_output_3}
|
||||
restore_mode: ALWAYS_ON
|
||||
- platform: monochromatic
|
||||
name: ${output_4_name}
|
||||
output: dmx_4
|
||||
id: light_test_4
|
||||
default_transition_length: 10s
|
||||
gamma_correct: 1
|
||||
gamma_correct: ${gamma_output_4}
|
||||
restore_mode: ALWAYS_ON
|
||||
- platform: monochromatic
|
||||
name: ${output_5_name}
|
||||
output: dmx_5
|
||||
id: light_test_5
|
||||
default_transition_length: 10s
|
||||
gamma_correct: 1
|
||||
default_transition_length: 3s
|
||||
gamma_correct: ${gamma_output_5}
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
- platform: monochromatic
|
||||
name: ${output_6_name}
|
||||
output: dmx_6
|
||||
id: light_test_6
|
||||
default_transition_length: 10s
|
||||
gamma_correct: 1
|
||||
default_transition_length: 3s
|
||||
gamma_correct: ${gamma_output_6}
|
||||
restore_mode: RESTORE_DEFAULT_OFF
|
||||
|
||||
##########################################################################################
|
||||
|
||||
@@ -91,7 +91,6 @@ substitutions:
|
||||
device_usr_button: GPIO04 # this is just a fake/safeish choice so it compiles with my generic yaml
|
||||
device_fading_led: GPIO13 # this is just a fake/safeish choice so it compiles with my generic yaml
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
@@ -125,26 +124,22 @@ packages:
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
#diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome CORE CONFIGURATION
|
||||
# https://esphome.io/components/esphome.html
|
||||
##########################################################################################
|
||||
esphome:
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- -DVTABLES_IN_FLASH
|
||||
- -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
name: "${device_name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "${description_comment}"
|
||||
area: "${device_area}"
|
||||
on_boot:
|
||||
# Run later so everything is initialised before we touch states.
|
||||
priority: 150
|
||||
priority: 200
|
||||
then:
|
||||
# Keep the HA dropdown in sync with the stored mode
|
||||
- lambda: |-
|
||||
@@ -184,6 +179,9 @@ esphome:
|
||||
# Boot complete: allow OFF handlers again
|
||||
- lambda: 'id(booting) = false;'
|
||||
|
||||
# NEW: force indicator OFF after boot logic
|
||||
- output.turn_off: green_led_out
|
||||
|
||||
# Only if you want to play with build flags...
|
||||
# platformio_options:
|
||||
# build_unflags:
|
||||
@@ -208,7 +206,7 @@ mdns:
|
||||
disabled: true # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 10sec # enough time to update values for reboots, but not enough to wear flash
|
||||
flash_write_interval: 2min # enough time to update values for reboots, but not enough to wear flash
|
||||
|
||||
##########################################################################################
|
||||
# GLOBAL VARIABLES
|
||||
@@ -274,11 +272,6 @@ globals:
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: '0'
|
||||
# last non-zero actual 0..100 used, for stable "Restore Brightness"
|
||||
- id: last_nonzero_brightness_pct
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: '0.0'
|
||||
# target for "Restore Brightness" scripted ramp
|
||||
- id: restore_target_pct
|
||||
type: float
|
||||
@@ -289,17 +282,12 @@ globals:
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
# volatile (non-persistent) last non-zero brightness during ramps
|
||||
- id: last_nonzero_tmp
|
||||
type: float
|
||||
restore_value: false
|
||||
initial_value: '0.0'
|
||||
# guards OFF persistence during startup caused by restore_mode: ALWAYS_OFF
|
||||
- id: booting
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'true'
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
- id: ramping_for_off
|
||||
type: bool
|
||||
restore_value: false
|
||||
@@ -328,7 +316,6 @@ status_led:
|
||||
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||
##########################################################################################
|
||||
mqtt:
|
||||
reboot_timeout: 0s
|
||||
on_message:
|
||||
# Light control to ramp up
|
||||
- topic: "${mqtt_local_command_topic}/light/set"
|
||||
@@ -402,8 +389,6 @@ button:
|
||||
# Stop any pending scripts (and their delayed actions)
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_up
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
// We are no longer ramping (up or down)
|
||||
@@ -420,14 +405,14 @@ button:
|
||||
call.perform();
|
||||
}
|
||||
|
||||
// Persist the exact frozen level so "Restore Brightness" survives a reboot
|
||||
// Persist the exact frozen level so restore survives a reboot
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct;
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# SELECT COMPONENT
|
||||
# https://esphome.io/components/select/index.html
|
||||
@@ -468,8 +453,8 @@ binary_sensor:
|
||||
pullup: true
|
||||
inverted: true
|
||||
filters:
|
||||
- delayed_on: 20ms
|
||||
- delayed_off: 20ms
|
||||
- delayed_on: 30ms
|
||||
- delayed_off: 30ms
|
||||
on_press:
|
||||
- if:
|
||||
condition:
|
||||
@@ -500,29 +485,16 @@ sensor:
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:percent
|
||||
accuracy_decimals: 0
|
||||
update_interval: 500ms # consider higher if you want fewer updates
|
||||
update_interval: 1s # consider 200ms if you want fewer updates
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
const auto &cv_now = id(mosfet_leds).current_values;
|
||||
|
||||
// Only persist exact last brightness while actually ON,
|
||||
// and not during the OFF ramp's brief floor-kick.
|
||||
if (cv_now.is_on()) {
|
||||
if (x > 0.5f) {
|
||||
if (!id(is_ramping)) id(last_nonzero_brightness_pct) = x;
|
||||
id(last_nonzero_tmp) = x;
|
||||
}
|
||||
} else {
|
||||
if (x > 0.5f) id(last_nonzero_tmp) = x;
|
||||
}
|
||||
|
||||
// If not suppressing sync, update the 0..100 slider only when its INT changes
|
||||
if (!id(suppress_slider_sync)) {
|
||||
float actual = x;
|
||||
float actual = x; // x is current Output (%)
|
||||
float minp = (float) id(min_brightness_pct);
|
||||
float maxp = (float) id(max_brightness_pct);
|
||||
if (maxp <= minp) maxp = minp + 1.0f;
|
||||
@@ -536,13 +508,14 @@ sensor:
|
||||
id(led_output_set_pct).publish_state(pos_i);
|
||||
}
|
||||
}
|
||||
|
||||
- platform: template
|
||||
id: mosfet_output_pwm_pct
|
||||
name: "${friendly_name} Output PWM (%)"
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:square-wave
|
||||
accuracy_decimals: 1
|
||||
update_interval: 500ms
|
||||
update_interval: 1s
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
if (!cv.is_on()) return 0.0f;
|
||||
@@ -553,6 +526,7 @@ sensor:
|
||||
if (pwm > 1.0f) pwm = 1.0f;
|
||||
return pwm * 100.0f;
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# OUTPUT COMPONENT
|
||||
# https://esphome.io/components/light/index.html
|
||||
@@ -738,7 +712,7 @@ number:
|
||||
float out_pct = minp + (pos * (maxp - minp) / 100.0f);
|
||||
if (out_pct > maxp) out_pct = maxp;
|
||||
return out_pct / 100.0f;
|
||||
transition_length: 500ms
|
||||
transition_length: 250ms
|
||||
- lambda: |-
|
||||
id(ramp_switch_target_on) = true;
|
||||
float pos = id(led_output_set_pct).state; // 1..100
|
||||
@@ -748,10 +722,6 @@ number:
|
||||
float out_pct = minp + (pos * (maxp - minp) / 100.0f);
|
||||
if (out_pct > maxp) out_pct = maxp;
|
||||
id(last_brightness_pct) = out_pct; // persist exact target now
|
||||
if (out_pct > 0.5f) {
|
||||
id(last_nonzero_brightness_pct) = out_pct;
|
||||
id(last_nonzero_tmp) = out_pct;
|
||||
}
|
||||
- delay: 400ms
|
||||
- lambda: 'id(suppress_slider_sync) = false;'
|
||||
|
||||
@@ -791,42 +761,14 @@ number:
|
||||
# Scripts can be executed nearly anywhere in your device configuration with a single call.
|
||||
##########################################################################################
|
||||
script:
|
||||
# Blink pattern while ramping UP: quick double-blink, pause, repeat
|
||||
- id: led_flash_up
|
||||
mode: restart
|
||||
then:
|
||||
- repeat:
|
||||
count: 1000000000 # effectively forever, but cancellable
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 400ms
|
||||
# Blink pattern while ramping DOWN: steady slow blink
|
||||
- id: led_flash_down
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 250ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 250ms
|
||||
|
||||
# Script: ramp up from current level. Obey global max.
|
||||
# Script: ramp up from current level. Obey global max. (LED ON while ramping)
|
||||
- id: ramp_on_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at at least the floor without a visible "pop".
|
||||
- if:
|
||||
condition:
|
||||
@@ -863,7 +805,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -871,17 +812,15 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp to a specific target (Restore Brightness path)
|
||||
# Script: ramp to a specific target (Restore Brightness path). (LED ON while ramping)
|
||||
- id: ramp_to_target_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at the floor cleanly.
|
||||
- if:
|
||||
condition:
|
||||
@@ -924,7 +863,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -932,10 +870,10 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF. (LED ON while ramping)
|
||||
- id: ramp_off_script
|
||||
mode: restart
|
||||
then:
|
||||
@@ -943,8 +881,7 @@ script:
|
||||
id(is_ramping) = true;
|
||||
id(ramping_for_off) = true;
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: led_flash_up
|
||||
- script.execute: led_flash_down
|
||||
- output.turn_on: green_led_out
|
||||
- light.turn_on:
|
||||
id: mosfet_leds
|
||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||
@@ -965,7 +902,6 @@ script:
|
||||
id: mosfet_leds
|
||||
transition_length: 150ms
|
||||
- delay: 150ms
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -1026,3 +962,5 @@ script:
|
||||
- light.turn_off:
|
||||
id: mosfet_leds
|
||||
transition_length: 0s
|
||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ packages:
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
#file: common/api_common.yaml
|
||||
file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
@@ -129,9 +129,9 @@ packages:
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
#diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome CORE CONFIGURATION
|
||||
@@ -184,6 +184,9 @@ esphome:
|
||||
# Boot complete: allow OFF handlers again
|
||||
- lambda: 'id(booting) = false;'
|
||||
|
||||
# NEW: force indicator OFF after boot logic
|
||||
- output.turn_off: green_led_out
|
||||
|
||||
# Only if you want to play with build flags...
|
||||
# platformio_options:
|
||||
# build_unflags:
|
||||
@@ -205,10 +208,10 @@ esp8266:
|
||||
restore_from_flash: true # restore some values on reboot
|
||||
|
||||
mdns:
|
||||
disabled: false # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
disabled: true # Disabling will make the build file smaller (and device is still available via static IP)
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 5sec # enough time to update values for reboots, but not enough to wear flash
|
||||
flash_write_interval: 2min # enough time to update values for reboots, but not enough to wear flash
|
||||
|
||||
##########################################################################################
|
||||
# GLOBAL VARIABLES
|
||||
@@ -274,11 +277,6 @@ globals:
|
||||
type: int
|
||||
restore_value: false
|
||||
initial_value: '0'
|
||||
# last non-zero actual 0..100 used, for stable "Restore Brightness"
|
||||
- id: last_nonzero_brightness_pct
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: '0.0'
|
||||
# target for "Restore Brightness" scripted ramp
|
||||
- id: restore_target_pct
|
||||
type: float
|
||||
@@ -289,17 +287,12 @@ globals:
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
# volatile (non-persistent) last non-zero brightness during ramps
|
||||
- id: last_nonzero_tmp
|
||||
type: float
|
||||
restore_value: false
|
||||
initial_value: '0.0'
|
||||
# guards OFF persistence during startup caused by restore_mode: ALWAYS_OFF
|
||||
- id: booting
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'true'
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
# true only while we are performing a ramp-down that briefly turns the light ON to hit the floor
|
||||
- id: ramping_for_off
|
||||
type: bool
|
||||
restore_value: false
|
||||
@@ -401,8 +394,6 @@ button:
|
||||
# Stop any pending scripts (and their delayed actions)
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_up
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
// We are no longer ramping (up or down)
|
||||
@@ -419,14 +410,14 @@ button:
|
||||
call.perform();
|
||||
}
|
||||
|
||||
// Persist the exact frozen level so "Restore Brightness" survives a reboot
|
||||
// Persist the exact frozen level so restore survives a reboot
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct;
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#########################################################################################
|
||||
# SELECT COMPONENT
|
||||
# https://esphome.io/components/select/index.html
|
||||
@@ -467,8 +458,8 @@ binary_sensor:
|
||||
pullup: true
|
||||
inverted: true
|
||||
filters:
|
||||
- delayed_on: 20ms
|
||||
- delayed_off: 20ms
|
||||
- delayed_on: 30ms
|
||||
- delayed_off: 30ms
|
||||
on_press:
|
||||
- if:
|
||||
condition:
|
||||
@@ -499,29 +490,16 @@ sensor:
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:percent
|
||||
accuracy_decimals: 0
|
||||
update_interval: 250ms # consider 200ms if you want fewer updates
|
||||
update_interval: 1s # consider 200ms if you want fewer updates
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
return cv.is_on() ? (cv.get_brightness() * 100.0f) : 0.0f;
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
const auto &cv_now = id(mosfet_leds).current_values;
|
||||
|
||||
// Only persist exact last brightness while actually ON,
|
||||
// and not during the OFF ramp's brief floor-kick.
|
||||
if (cv_now.is_on()) {
|
||||
if (x > 0.5f) {
|
||||
if (!id(is_ramping)) id(last_nonzero_brightness_pct) = x;
|
||||
id(last_nonzero_tmp) = x;
|
||||
}
|
||||
} else {
|
||||
if (x > 0.5f) id(last_nonzero_tmp) = x;
|
||||
}
|
||||
|
||||
// If not suppressing sync, update the 0..100 slider only when its INT changes
|
||||
if (!id(suppress_slider_sync)) {
|
||||
float actual = x;
|
||||
float actual = x; // x is current Output (%)
|
||||
float minp = (float) id(min_brightness_pct);
|
||||
float maxp = (float) id(max_brightness_pct);
|
||||
if (maxp <= minp) maxp = minp + 1.0f;
|
||||
@@ -535,13 +513,14 @@ sensor:
|
||||
id(led_output_set_pct).publish_state(pos_i);
|
||||
}
|
||||
}
|
||||
|
||||
- platform: template
|
||||
id: mosfet_output_pwm_pct
|
||||
name: "${friendly_name} Output PWM (%)"
|
||||
unit_of_measurement: "%"
|
||||
icon: mdi:square-wave
|
||||
accuracy_decimals: 1
|
||||
update_interval: 250ms
|
||||
update_interval: 1s
|
||||
lambda: |-
|
||||
const auto &cv = id(mosfet_leds).current_values;
|
||||
if (!cv.is_on()) return 0.0f;
|
||||
@@ -552,6 +531,7 @@ sensor:
|
||||
if (pwm > 1.0f) pwm = 1.0f;
|
||||
return pwm * 100.0f;
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# OUTPUT COMPONENT
|
||||
# https://esphome.io/components/light/index.html
|
||||
@@ -747,10 +727,6 @@ number:
|
||||
float out_pct = minp + (pos * (maxp - minp) / 100.0f);
|
||||
if (out_pct > maxp) out_pct = maxp;
|
||||
id(last_brightness_pct) = out_pct; // persist exact target now
|
||||
if (out_pct > 0.5f) {
|
||||
id(last_nonzero_brightness_pct) = out_pct;
|
||||
id(last_nonzero_tmp) = out_pct;
|
||||
}
|
||||
- delay: 400ms
|
||||
- lambda: 'id(suppress_slider_sync) = false;'
|
||||
|
||||
@@ -790,43 +766,14 @@ number:
|
||||
# Scripts can be executed nearly anywhere in your device configuration with a single call.
|
||||
##########################################################################################
|
||||
script:
|
||||
# Blink pattern while ramping UP: quick double-blink, pause, repeat
|
||||
- id: led_flash_up
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 100ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 400ms
|
||||
# Blink pattern while ramping DOWN: steady slow blink
|
||||
- id: led_flash_down
|
||||
mode: restart
|
||||
then:
|
||||
- while:
|
||||
condition:
|
||||
lambda: 'return true;'
|
||||
then:
|
||||
- output.turn_on: green_led_out
|
||||
- delay: 250ms
|
||||
- output.turn_off: green_led_out
|
||||
- delay: 250ms
|
||||
|
||||
# Script: ramp up from current level. Obey global max.
|
||||
# Script: ramp up from current level. Obey global max. (LED ON while ramping)
|
||||
- id: ramp_on_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at at least the floor without a visible "pop".
|
||||
- if:
|
||||
condition:
|
||||
@@ -863,7 +810,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -871,17 +817,15 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp to a specific target (Restore Brightness path)
|
||||
# Script: ramp to a specific target (Restore Brightness path). (LED ON while ramping)
|
||||
- id: ramp_to_target_script
|
||||
mode: restart
|
||||
then:
|
||||
- lambda: 'id(is_ramping) = true;'
|
||||
- script.stop: ramp_off_script
|
||||
- script.stop: led_flash_down
|
||||
- script.execute: led_flash_up
|
||||
- output.turn_on: green_led_out
|
||||
# Ensure we start at the floor cleanly.
|
||||
- if:
|
||||
condition:
|
||||
@@ -924,7 +868,6 @@ script:
|
||||
id(last_ramp_ms) = (int) (id(ramp_up_ms) * frac);
|
||||
return (uint32_t) id(last_ramp_ms);
|
||||
- delay: !lambda 'return (uint32_t) id(last_ramp_ms);'
|
||||
- script.stop: led_flash_up
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -932,10 +875,10 @@ script:
|
||||
if (cv.is_on()) {
|
||||
float pct = cv.get_brightness() * 100.0f;
|
||||
id(last_brightness_pct) = pct; // persist final level
|
||||
if (pct > 0.5f) id(last_nonzero_brightness_pct) = pct;
|
||||
}
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF
|
||||
|
||||
# Script: ramp down from current level to floor, then cleanly cut to OFF. (LED ON while ramping)
|
||||
- id: ramp_off_script
|
||||
mode: restart
|
||||
then:
|
||||
@@ -943,8 +886,7 @@ script:
|
||||
id(is_ramping) = true;
|
||||
id(ramping_for_off) = true;
|
||||
- script.stop: ramp_on_script
|
||||
- script.stop: led_flash_up
|
||||
- script.execute: led_flash_down
|
||||
- output.turn_on: green_led_out
|
||||
- light.turn_on:
|
||||
id: mosfet_leds
|
||||
brightness: !lambda 'return id(min_brightness_pct) / 100.0f;'
|
||||
@@ -965,7 +907,6 @@ script:
|
||||
id: mosfet_leds
|
||||
transition_length: 150ms
|
||||
- delay: 150ms
|
||||
- script.stop: led_flash_down
|
||||
- output.turn_off: green_led_out
|
||||
- lambda: |-
|
||||
id(is_ramping) = false;
|
||||
@@ -1026,3 +967,4 @@ script:
|
||||
- light.turn_off:
|
||||
id: mosfet_leds
|
||||
transition_length: 0s
|
||||
- output.turn_off: green_led_out # make sure LED is off if no ramp
|
||||
@@ -0,0 +1,395 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# LOUNGE MIDDLE LIGHTSwITCH
|
||||
# V3.5 2025-07-28 YAML tidyups
|
||||
##########################################################################################
|
||||
# Zemismart KS-811 Triple push button
|
||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||
#
|
||||
# NOTES
|
||||
# -
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# 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-loungemiddleswitch"
|
||||
friendly_name: "Lounge Middle Lightswitch (3)"
|
||||
description_comment: "Lounge Main Lightswitch using a Zemismart KS-811 Triple Push Button. Downlights South (1), Downlights Middle (2), Downlights North (3)"
|
||||
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Zemismart Technologies.KS-811 Triple" # Project Details
|
||||
project_version: "v3.5" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
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-loungemiddleswitch_ip
|
||||
#mqtt_command_main_topic: !secret mqtt_local_command_main_topic
|
||||
#mqtt_status_main_topic: !secret mqtt_local_status_main_topic
|
||||
|
||||
# Device Settings
|
||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||
update_interval: "60s" # update time for for general sensors etc
|
||||
|
||||
# MQTT LOCAL Controls
|
||||
#mqtt_device_name: "lounge-main-lights"
|
||||
#mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||
#mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
||||
|
||||
# MQTT REMOTE Controls
|
||||
|
||||
# Switch/Relay/Button Naming & Icons
|
||||
#relay_icon: "mdi:lightbulb-group"
|
||||
switch_1_name: "Downlights South" # Lights are connected via DMX dimmer (another esphome controller) (4 Downlights)
|
||||
switch_2_name: "Downlights Middle" # Lights are connected via DMX dimmer (another esphome controller) (6 Downlights)
|
||||
switch_3_name: "Downlights North" # Lights are directly connected (2 downlights)
|
||||
|
||||
#########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#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
|
||||
area: "${device_area}"
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
|
||||
api:
|
||||
on_client_connected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "API connected: applying override (override=%s)"
|
||||
args: ['id(ha_loss_override).state ? "true" : "false"']
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: ha_loss_override
|
||||
then:
|
||||
- switch.turn_on: Relay_1
|
||||
- switch.turn_on: Relay_2
|
||||
else:
|
||||
- switch.turn_off: Relay_1
|
||||
- switch.turn_off: Relay_2
|
||||
|
||||
on_client_disconnected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: WARN
|
||||
format: "API disconnected: switching to manual/offline behavior"
|
||||
|
||||
#########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#########################################################################################
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||
board_flash_mode: dout # Default is dout
|
||||
|
||||
#########################################################################################
|
||||
# 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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
#########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO02
|
||||
inverted: yes
|
||||
|
||||
#########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#########################################################################################
|
||||
binary_sensor:
|
||||
# GPIO16 for KS-811 first button UNLESS
|
||||
# it is a single button KS-811 in which case it is GPIO00
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO16
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 1: ${switch_1_name}"
|
||||
on_multi_click:
|
||||
|
||||
# --- Single short click ---
|
||||
# Online (and override ON): use HA's last scene to decide.
|
||||
# If last != "All Off" → send "All Off"
|
||||
# If last == "All Off" → send "Bright"
|
||||
# Offline (and override ON): toggle physical Relay_1
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
// Defensive: treat empty/unknown as "not All Off" so we go to a safe "All Off".
|
||||
auto s = id(ha_last_scene).state;
|
||||
if (s.empty() || s == "unknown" || s == "unavailable") return true;
|
||||
return s != "All Off";
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "All Off"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN1: Single click (online) → Last scene was not 'All Off' → Set 'All Off'"
|
||||
else:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Bright"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN1: Single click (online) → Last scene was 'All Off' → Set 'Bright'"
|
||||
else:
|
||||
# OFFLINE path: only act if override ON; toggle physical relay
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- not:
|
||||
api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_1).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN1: Single click (offline) → Relay_1 OFF"
|
||||
else:
|
||||
- switch.turn_on: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN1: Single click (offline) → Relay_1 ON"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN1: Single click ignored (override OFF)"
|
||||
|
||||
# GPIO05 for second button (only for KS-811-2 Double or -3 Triple)
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO05
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 2: ${switch_2_name}"
|
||||
on_multi_click:
|
||||
# --- Single short click ---
|
||||
# Online (and override ON): use HA's last scene to decide.
|
||||
# If last != "All Off" → send "All Off"
|
||||
# If last == "All Off" → send "Bright"
|
||||
# Offline (and override ON): toggle physical Relay_1
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- api.connected:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "TV General"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN2: Single click (online) → Set 'TV General' Scene"
|
||||
else:
|
||||
# OFFLINE path: only act if override ON; toggle physical relay
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- not:
|
||||
api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_2).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_2
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN2: Single click (offline) → Relay_2 OFF"
|
||||
else:
|
||||
- switch.turn_on: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN2: Single click (offline) → Relay_2 ON"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click ignored"
|
||||
|
||||
# GPIO04 for third button (only for KS-811-3 Triple)
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO4
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 3: ${switch_3_name}"
|
||||
on_multi_click:
|
||||
# --- Single short click ---
|
||||
# Online (and override ON): use HA's last scene to decide.
|
||||
# If last != "All Off" → send "All Off"
|
||||
# If last == "All Off" → send "Bright"
|
||||
# Offline (and override ON): toggle physical Relay_1
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- api.connected:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Reading On/Off"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN2: Single click (online) → Set 'Reaading On/Off' Scene"
|
||||
else:
|
||||
# OFFLINE path: only act if override ON; toggle physical relay
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- not:
|
||||
api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_2).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_2
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN2: Single click (offline) → Relay_2 OFF"
|
||||
else:
|
||||
- switch.turn_on: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN2: Single click (offline) → Relay_2 ON"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click ignored"
|
||||
|
||||
#########################################################################################
|
||||
# TEXT SENSOR COMPONENT
|
||||
#
|
||||
#########################################################################################
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: ha_last_scene
|
||||
entity_id: input_text.lounge_last_scene
|
||||
# logging: helpful when testing
|
||||
on_value:
|
||||
- logger.log:
|
||||
level: DEBUG
|
||||
format: "HA last scene now: %s"
|
||||
args: ["x.c_str()"]
|
||||
|
||||
#########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
#########################################################################################
|
||||
switch:
|
||||
# GPIO13 for KS-811 first button UNLESS it is KS-811-1 then it is GIPO12
|
||||
- platform: gpio
|
||||
name: "Relay 1: ${switch_1_name}"
|
||||
pin: GPIO13
|
||||
id: Relay_1
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
# GPIO12 for second relay (only for KS-811-2 Double or -3 Triple)
|
||||
- platform: gpio
|
||||
name: "Relay 2: ${switch_2_name}"
|
||||
pin: GPIO12
|
||||
id: Relay_2
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
# GPIO14 for third relay (only for KS-811-3 Triple)
|
||||
- platform: gpio
|
||||
name: "Relay 3: ${switch_3_name}"
|
||||
pin: GPIO14
|
||||
id: Relay_3
|
||||
|
||||
# HA Loss manual override (default ON; persists across restarts)
|
||||
- platform: template
|
||||
name: "HA Loss manual override"
|
||||
id: ha_loss_override
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# LOUNGE NORTH SWITCH (Single Switch into hallway)
|
||||
# V4.0 2025-10-01 Copy from other device
|
||||
##########################################################################################
|
||||
# Zemismart KS-811 Single push button
|
||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||
#
|
||||
# NOTES
|
||||
# -
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# 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-loungenorthswitch"
|
||||
friendly_name: "Lounge North Single Switch (1)"
|
||||
description_comment: "Main Lounge from hallway Lightswitch using a Zemismart KS-811 Single Push Button. Main Lights (1)"
|
||||
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Zemismart Technologies.KS-811 Single" # Project Details
|
||||
project_version: "v4.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
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-loungenorthswitch_ip
|
||||
#mqtt_command_main_topic: !secret mqtt_local_command_main_topic
|
||||
#mqtt_status_main_topic: !secret mqtt_local_status_main_topic
|
||||
|
||||
# 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
|
||||
|
||||
# MQTT LOCAL Controls
|
||||
#mqtt_device_name: "lounge-north-switch"
|
||||
#mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||
#mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
||||
|
||||
# MQTT REMOTE Controls
|
||||
#mqtt_remote_device_name: "lounge-main-lights"
|
||||
#mqtt_remote_device_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device_name}"
|
||||
#mqtt_remote_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device_name}" # Topic we will use to view status locally without HA
|
||||
#mqtt_remote_device_command_on: "On"
|
||||
#mqtt_remote_device_command_off: "Off"
|
||||
|
||||
# Switch/Relay/Button Naming & Icons
|
||||
switch_1_name: "Main Lights" # NOTE there is no physical connection to the lights on this switch, it is connected to the dimmer ESPhome for the pelmet lights
|
||||
|
||||
#########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#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
|
||||
area: "${device_area}"
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
|
||||
api:
|
||||
on_client_connected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "API connected: applying override (override=%s)"
|
||||
args: ['id(ha_loss_override).state ? "true" : "false"']
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: ha_loss_override
|
||||
then:
|
||||
- switch.turn_on: Relay_1
|
||||
else:
|
||||
- switch.turn_off: Relay_1
|
||||
|
||||
on_client_disconnected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: WARN
|
||||
format: "API disconnected: switching to manual/offline behavior"
|
||||
|
||||
#########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#########################################################################################
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||
board_flash_mode: dout # Default is dout
|
||||
|
||||
#########################################################################################
|
||||
# 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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
#########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO02
|
||||
inverted: yes
|
||||
|
||||
#########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#########################################################################################
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO0
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 1: ${switch_1_name}"
|
||||
on_multi_click:
|
||||
|
||||
# --- Double click: send "Night Light" (only if HA connected). ---
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Night Light"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Double click → Scene Night Light"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Double click ignored (no HA connection)"
|
||||
|
||||
# --- Single short click ---
|
||||
# Online (and override ON): use HA's last scene to decide.
|
||||
# If last != "All Off" → send "All Off"
|
||||
# If last == "All Off" → send "Bright"
|
||||
# Offline (and override ON): toggle physical Relay_1
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
// Defensive: treat empty/unknown as "not All Off" so we go to a safe "All Off".
|
||||
auto s = id(ha_last_scene).state;
|
||||
if (s.empty() || s == "unknown" || s == "unavailable") return true;
|
||||
return s != "All Off";
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "All Off"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (online) → Last scene was not 'All Off' → Set 'All Off'"
|
||||
else:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Bright"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (online) → Last scene was 'All Off' → Set 'Bright'"
|
||||
else:
|
||||
# OFFLINE path: only act if override ON; toggle physical relay
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- not:
|
||||
api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_1).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (offline) → Relay_1 OFF"
|
||||
else:
|
||||
- switch.turn_on: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (offline) → Relay_1 ON"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click ignored (override OFF)"
|
||||
|
||||
# --- Long hold: ON for at least 4s (only if HA connected) ---
|
||||
- timing:
|
||||
- ON for at least 4s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "All Off"
|
||||
- homeassistant.event:
|
||||
event: esphome.lounge_switch_hold
|
||||
data:
|
||||
action: "hold"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Long press → Scene All Off + HA event (hold)"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Long press ignored (no HA connection)"
|
||||
|
||||
#########################################################################################
|
||||
# TEXT SENSOR COMPONENT
|
||||
#
|
||||
#########################################################################################
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: ha_last_scene
|
||||
entity_id: input_text.lounge_last_scene
|
||||
# logging: helpful when testing
|
||||
on_value:
|
||||
- logger.log:
|
||||
level: DEBUG
|
||||
format: "HA last scene now: %s"
|
||||
args: ["x.c_str()"]
|
||||
|
||||
#########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
#########################################################################################
|
||||
switch:
|
||||
# GPIO13 for KS-811 first button UNLESS it is KS-811-1 then it is GPIO12
|
||||
- platform: gpio
|
||||
name: "Relay 1: ${switch_1_name}"
|
||||
pin: GPIO12
|
||||
id: Relay_1
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
# HA Loss manual override (default ON; persists across restarts)
|
||||
- platform: template
|
||||
name: "HA Loss manual override"
|
||||
id: ha_loss_override
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,188 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# LOUNGE SOUTH LEFT LIGHTSWITCH
|
||||
# V4.0 2025-10-04 Copied from other device
|
||||
##########################################################################################
|
||||
# Zemismart KS-811 Double push button
|
||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||
#
|
||||
# NOTES
|
||||
# -
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# 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-loungesouthleftswitch"
|
||||
friendly_name: "Lounge South Left Lightswitch (2)"
|
||||
description_comment: "Lounge South Left Lightswitch using a Zemismart KS-811 Double Push Button. Wall Washer Left (1), Outside Light 1 (2)"
|
||||
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Zemismart Technologies.KS-811 Double" # Project Details
|
||||
project_version: "v4.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
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-loungesouthleftswitch_ip
|
||||
#mqtt_local_command_main_topic: !secret mqtt_local_command_main_topic
|
||||
#mqtt_local_status_main_topic: !secret mqtt_local_status_main_topic
|
||||
|
||||
# Device Settings
|
||||
#relay_icon: "mdi:lightbulb-group"
|
||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||
update_interval: "60s" # update time for for general sensors etc
|
||||
|
||||
# MQTT LOCAL Controls
|
||||
#mqtt_device_name: "bedroom2-lights"
|
||||
#mqtt_local_command_topic: "${mqtt_local_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||
#mqtt_local_status_topic: "${mqtt_local_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
||||
|
||||
# Switch Naming
|
||||
switch_1_name: "Wall Washer Left"
|
||||
switch_2_name: "Outside Light 1"
|
||||
#switch_3_name: "Nil"
|
||||
|
||||
#########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#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
|
||||
area: "${device_area}"
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
#on_boot:
|
||||
# priority: 200
|
||||
# then:
|
||||
# - switch.turn_on: Relay_2
|
||||
|
||||
#########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#########################################################################################
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||
board_flash_mode: dout # Default is dout
|
||||
|
||||
#########################################################################################
|
||||
# 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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
#########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO2
|
||||
inverted: yes
|
||||
|
||||
#########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#########################################################################################
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO16
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 1: ${switch_1_name}"
|
||||
on_press:
|
||||
- switch.toggle: Relay_1
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO05
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 2: ${switch_2_name}"
|
||||
on_press:
|
||||
- switch.toggle: Relay_2
|
||||
|
||||
# KS-811-2 is a double only
|
||||
# - platform: gpio
|
||||
# pin:
|
||||
# number: GPIO4
|
||||
# mode: INPUT
|
||||
# inverted: True
|
||||
# name: "Button 3: ${switch_3_name}"
|
||||
# on_press:
|
||||
# - switch.toggle: Relay_3
|
||||
|
||||
#########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
#########################################################################################
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "Relay 1: ${switch_1_name}"
|
||||
pin: GPIO13
|
||||
id: Relay_1
|
||||
|
||||
- platform: gpio
|
||||
name: "Relay 2: ${switch_2_name}"
|
||||
pin: GPIO12
|
||||
id: Relay_2
|
||||
|
||||
# KS-811-2 is a double only
|
||||
# - platform: gpio
|
||||
# name: "Relay 3: ${switch_3_name}"
|
||||
# pin: GPIO14
|
||||
# id: Relay_3
|
||||
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# LOUNGE SOUTH RIGHT LIGHTSWITCH
|
||||
# V4.0 2025-10-04 Copied from other device
|
||||
##########################################################################################
|
||||
# Zemismart KS-811 Triple push button
|
||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||
#
|
||||
# NOTES
|
||||
# -
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# 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-loungesouthrightswitch"
|
||||
friendly_name: "Lounge South Right Lightswitch (3)"
|
||||
description_comment: "Lounge South Right Lightswitch using a Zemismart KS-811 Triple Push Button. Spare (1), Wall Washer Right (2), Breakfastbar LEDs (3)"
|
||||
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Zemismart Technologies.KS-811 Triple" # Project Details
|
||||
project_version: "v4.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
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-loungesouthrightswitch_ip
|
||||
#mqtt_local_command_main_topic: !secret mqtt_local_command_main_topic
|
||||
#mqtt_local_status_main_topic: !secret mqtt_local_status_main_topic
|
||||
|
||||
# Device Settings
|
||||
#relay_icon: "mdi:lightbulb-group"
|
||||
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
|
||||
update_interval: "60s" # update time for for general sensors etc
|
||||
|
||||
# MQTT LOCAL Controls
|
||||
#mqtt_device_name: "bedroom2-lights"
|
||||
#mqtt_local_command_topic: "${mqtt_local_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||
#mqtt_local_status_topic: "${mqtt_local_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
||||
|
||||
# Switch Naming
|
||||
switch_1_name: "Spare"
|
||||
switch_2_name: "Wall Washer Right"
|
||||
switch_3_name: "Breakfast Bar LEDs" # Connected to another esphome device at the breakfast bar LEDs
|
||||
|
||||
#########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#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
|
||||
area: "${device_area}"
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
|
||||
api:
|
||||
on_client_connected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "API connected: applying override (override=%s)"
|
||||
args: ['id(ha_loss_override).state ? "true" : "false"']
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: ha_loss_override
|
||||
then:
|
||||
- switch.turn_on: Relay_3
|
||||
else:
|
||||
- switch.turn_off: Relay_3
|
||||
|
||||
on_client_disconnected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: WARN
|
||||
format: "API disconnected: switching to manual/offline behavior"
|
||||
|
||||
#########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#########################################################################################
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||
board_flash_mode: dout # Default is dout
|
||||
|
||||
#########################################################################################
|
||||
# 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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
#########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO2
|
||||
inverted: yes
|
||||
|
||||
#########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#########################################################################################
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO16
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 1: ${switch_1_name}"
|
||||
on_press:
|
||||
- switch.toggle: Relay_1
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO05
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 2: ${switch_2_name}"
|
||||
on_press:
|
||||
- switch.toggle: Relay_2
|
||||
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO4
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 3: ${switch_3_name}"
|
||||
on_multi_click:
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- not: api.connected
|
||||
- switch.is_on: ha_loss_override
|
||||
then:
|
||||
- switch.toggle: Relay_3
|
||||
else: []
|
||||
|
||||
#########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
#########################################################################################
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "Relay 1: ${switch_1_name}"
|
||||
pin: GPIO13
|
||||
id: Relay_1
|
||||
|
||||
- platform: gpio
|
||||
name: "Relay 2: ${switch_2_name}"
|
||||
pin: GPIO12
|
||||
id: Relay_2
|
||||
|
||||
- platform: gpio
|
||||
name: "Relay 3: ${switch_3_name}"
|
||||
pin: GPIO14
|
||||
id: Relay_3
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
# HA Loss manual override (default ON; persists across restarts)
|
||||
- platform: template
|
||||
name: "HA Loss manual override"
|
||||
id: ha_loss_override
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# LOUNGE WEST SWITCH (Single Switch from entranceway)
|
||||
# V4.0 2025-10-04 Copy from other device
|
||||
##########################################################################################
|
||||
# Zemismart KS-811 Single push button
|
||||
# pinout/schematic https://community.home-assistant.io/t/zemismart-ks-811-working-with-esphome/
|
||||
#
|
||||
# NOTES
|
||||
# -
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# 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-loungewestswitch"
|
||||
friendly_name: "Lounge West Single Switch (1)"
|
||||
description_comment: "Main Lounge from entranceway lightswitch using a Zemismart KS-811 Single Push Button. Main Lights (1)"
|
||||
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Zemismart Technologies.KS-811 Single" # Project Details
|
||||
project_version: "v4.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
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-loungewestswitch_ip
|
||||
#mqtt_command_main_topic: !secret mqtt_local_command_main_topic
|
||||
#mqtt_status_main_topic: !secret mqtt_local_status_main_topic
|
||||
|
||||
# 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
|
||||
|
||||
# MQTT LOCAL Controls
|
||||
#mqtt_device_name: "lounge-north-switch"
|
||||
#mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command this locally without HA
|
||||
#mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_device_name}" # Topic we will use to view status locally without HA
|
||||
|
||||
# MQTT REMOTE Controls
|
||||
#mqtt_remote_device_name: "lounge-main-lights"
|
||||
#mqtt_remote_device_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device_name}"
|
||||
#mqtt_remote_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device_name}" # Topic we will use to view status locally without HA
|
||||
#mqtt_remote_device_command_on: "On"
|
||||
#mqtt_remote_device_command_off: "Off"
|
||||
|
||||
# Switch/Relay/Button Naming & Icons
|
||||
switch_1_name: "Main Lights" # NOTE there is no physical connection to the lights on this switch, it is connected to the dimmer ESPhome for the pelmet lights
|
||||
|
||||
#########################################################################################
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#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
|
||||
area: "${device_area}"
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
|
||||
api:
|
||||
on_client_connected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "API connected: applying override (override=%s)"
|
||||
args: ['id(ha_loss_override).state ? "true" : "false"']
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: ha_loss_override
|
||||
then:
|
||||
- switch.turn_on: Relay_1
|
||||
else:
|
||||
- switch.turn_off: Relay_1
|
||||
|
||||
on_client_disconnected:
|
||||
then:
|
||||
- logger.log:
|
||||
level: WARN
|
||||
format: "API disconnected: switching to manual/offline behavior"
|
||||
|
||||
#########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
#########################################################################################
|
||||
esp8266:
|
||||
board: esp01_1m
|
||||
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
|
||||
board_flash_mode: dout # Default is dout
|
||||
|
||||
#########################################################################################
|
||||
# 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)
|
||||
#esp8266_store_log_strings_in_flash: false
|
||||
#tx_buffer_size: 64
|
||||
|
||||
#########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
#########################################################################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO02
|
||||
inverted: yes
|
||||
|
||||
#########################################################################################
|
||||
# BINARY SENSORS
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#########################################################################################
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO0
|
||||
mode: INPUT
|
||||
inverted: True
|
||||
name: "Button 1: ${switch_1_name}"
|
||||
on_multi_click:
|
||||
|
||||
# --- Double click: send "Night Light" (only if HA connected). ---
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at most 0.5s
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.2s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Night Light"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Double click → Scene Night Light"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Double click ignored (no HA connection)"
|
||||
|
||||
# --- Single short click ---
|
||||
# Online (and override ON): use HA's last scene to decide.
|
||||
# If last != "All Off" → send "All Off"
|
||||
# If last == "All Off" → send "Bright"
|
||||
# Offline (and override ON): toggle physical Relay_1
|
||||
- timing:
|
||||
- ON for at most 0.5s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: |-
|
||||
// Defensive: treat empty/unknown as "not All Off" so we go to a safe "All Off".
|
||||
auto s = id(ha_last_scene).state;
|
||||
if (s.empty() || s == "unknown" || s == "unavailable") return true;
|
||||
return s != "All Off";
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "All Off"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (online) → Last scene was not 'All Off' → Set 'All Off'"
|
||||
else:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Bright"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (online) → Last scene was 'All Off' → Set 'Bright'"
|
||||
else:
|
||||
# OFFLINE path: only act if override ON; toggle physical relay
|
||||
- if:
|
||||
condition:
|
||||
and:
|
||||
- switch.is_on: ha_loss_override
|
||||
- not:
|
||||
api.connected:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
lambda: 'return id(Relay_1).state;'
|
||||
then:
|
||||
- switch.turn_off: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (offline) → Relay_1 OFF"
|
||||
else:
|
||||
- switch.turn_on: Relay_1
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click (offline) → Relay_1 ON"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Single click ignored (override OFF)"
|
||||
|
||||
# --- Long hold: ON for at least 4s (only if HA connected) ---
|
||||
- timing:
|
||||
- ON for at least 4s
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
api.connected:
|
||||
then:
|
||||
- homeassistant.service:
|
||||
service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "All Off"
|
||||
- homeassistant.event:
|
||||
event: esphome.lounge_switch_hold
|
||||
data:
|
||||
action: "hold"
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Long press → Scene All Off + HA event (hold)"
|
||||
else:
|
||||
- logger.log:
|
||||
level: INFO
|
||||
format: "BTN: Long press ignored (no HA connection)"
|
||||
|
||||
#########################################################################################
|
||||
# TEXT SENSOR COMPONENT
|
||||
#
|
||||
#########################################################################################
|
||||
text_sensor:
|
||||
- platform: homeassistant
|
||||
id: ha_last_scene
|
||||
entity_id: input_text.lounge_last_scene
|
||||
# logging: helpful when testing
|
||||
on_value:
|
||||
- logger.log:
|
||||
level: DEBUG
|
||||
format: "HA last scene now: %s"
|
||||
args: ["x.c_str()"]
|
||||
|
||||
#########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
# https://esphome.io/components/switch/
|
||||
#########################################################################################
|
||||
switch:
|
||||
# GPIO13 for KS-811 first button UNLESS it is KS-811-1 then it is GPIO12
|
||||
- platform: gpio
|
||||
name: "Relay 1: ${switch_1_name}"
|
||||
pin: GPIO12
|
||||
id: Relay_1
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
# HA Loss manual override (default ON; persists across restarts)
|
||||
- platform: template
|
||||
name: "HA Loss manual override"
|
||||
id: ha_loss_override
|
||||
optimistic: true
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
|
||||
|
||||
@@ -52,29 +52,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -35,29 +35,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -44,29 +44,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
# Device Specific included packages
|
||||
common_athompowermonV3: !include
|
||||
|
||||
@@ -55,29 +55,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -83,29 +83,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
@@ -116,12 +124,12 @@ esphome:
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||
area: "${device_area}"
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- "-Os" # optimize for size
|
||||
- "-Wl,--gc-sections" # drop unused code/data
|
||||
- "-fno-exceptions" # strip C++ exceptions
|
||||
- "-fno-rtti" # strip C++ RTTI
|
||||
# platformio_options:
|
||||
# build_flags:
|
||||
# - "-Os" # optimize for size
|
||||
# - "-Wl,--gc-sections" # drop unused code/data
|
||||
# - "-fno-exceptions" # strip C++ exceptions
|
||||
# - "-fno-rtti" # strip C++ RTTI
|
||||
on_boot:
|
||||
priority: 900 # High priority to run after globals are initialized
|
||||
then:
|
||||
|
||||
@@ -52,29 +52,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -42,29 +42,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -54,29 +54,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome CORE CONFIGURATION
|
||||
|
||||
@@ -65,29 +65,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
@@ -98,12 +106,12 @@ esphome:
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "${description_comment}" # Appears on the esphome page in HA
|
||||
area: "${device_area}"
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- "-Os" # optimize for size
|
||||
- "-Wl,--gc-sections" # drop unused code/data
|
||||
- "-fno-exceptions" # strip C++ exceptaions
|
||||
- "-fno-rtti" # strip C++ RTTI
|
||||
# platformio_options:
|
||||
# build_flags:
|
||||
# - "-Os" # optimize for size
|
||||
# - "-Wl,--gc-sections" # drop unused code/data
|
||||
# - "-fno-exceptions" # strip C++ exceptaions
|
||||
# - "-fno-rtti" # strip C++ RTTI
|
||||
|
||||
##########################################################################################
|
||||
# ESP Platform and Framework
|
||||
|
||||
@@ -48,29 +48,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -47,29 +47,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
#############################################
|
||||
# ESPHome
|
||||
|
||||
@@ -48,29 +48,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
#diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -86,10 +86,6 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
##################################################
|
||||
# MANDATORY packages (won't compile without them!)
|
||||
##################################################
|
||||
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
@@ -98,10 +94,6 @@ packages:
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
##################################################
|
||||
# OPTIONAL packages (comment if you don't want them)
|
||||
##################################################
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
@@ -109,34 +101,22 @@ packages:
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Lite Sensors ####
|
||||
# Option of everything, or a lite version
|
||||
common_lite_sensors: !include
|
||||
file: common/sensors_common_lite.yaml
|
||||
|
||||
#### DIAGNOSTICS General Sensors ####
|
||||
# Option of everything, or a lite version
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
|
||||
#### DEBUGGING Sensors ####
|
||||
# A count of various resets
|
||||
#common_resetcount_debugging: !include
|
||||
# file: common/resetcount_common.yaml
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
# Device Specific included packages
|
||||
common_athompowermonV3: !include
|
||||
|
||||
@@ -59,29 +59,37 @@ substitutions:
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
file: common/network_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
|
||||
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
file: common/api_common.yaml
|
||||
#file: common/api_common_noencryption.yaml
|
||||
vars:
|
||||
local_api_key: "${api_key}"
|
||||
#common_webportal: !include
|
||||
# file: common/webportal_common.yaml
|
||||
|
||||
#### MQTT ####
|
||||
common_mqtt: !include
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
common_sntp: !include
|
||||
file: common/sntp_common.yaml
|
||||
common_general_sensors: !include
|
||||
file: common/sensors_common.yaml
|
||||
vars:
|
||||
local_friendly_name: "${friendly_name}"
|
||||
local_update_interval: "${update_interval}"
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#common_webportal: !include common/webportal_common.yaml
|
||||
#### SNTP (Only use if you want/need accurate timeclocks) ####
|
||||
#common_sntp: !include common/sntp_common.yaml
|
||||
|
||||
#### DIAGNOSTICS Sensors ####
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
diag_debug: !include common/include_debug_diag_sensors.yaml
|
||||
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
# yaml-language-server: $schema=null
|
||||
###############################################################################
|
||||
# PACKAGE: Lounge scenes (delta-only settings) + manual override
|
||||
###############################################################################
|
||||
|
||||
input_select:
|
||||
lounge_scene:
|
||||
name: Lounge Scene
|
||||
options:
|
||||
- "Select Scene:"
|
||||
- Bright
|
||||
- TV General
|
||||
- Movie
|
||||
- Reading On/Off
|
||||
- Night Light
|
||||
- Warm Cozy
|
||||
- All Off
|
||||
initial: "Select Scene:"
|
||||
|
||||
input_boolean:
|
||||
lounge_manual_override:
|
||||
name: Lounge Lighting Scene Manual Override
|
||||
initial: off
|
||||
|
||||
input_text:
|
||||
lounge_last_scene:
|
||||
name: Lounge Last Scene
|
||||
initial: "All Off"
|
||||
max: 40
|
||||
|
||||
timer:
|
||||
lounge_override_timer:
|
||||
name: Lounge Lighting Scene Override Timer
|
||||
duration: "02:00:00"
|
||||
|
||||
###############################################################################
|
||||
# SCRIPTS
|
||||
###############################################################################
|
||||
script:
|
||||
lounge_set_scene:
|
||||
alias: "Lounge: Set scene by name"
|
||||
mode: restart
|
||||
fields:
|
||||
scene_name:
|
||||
description: One of the options from input_select.lounge_scene
|
||||
sequence:
|
||||
- service: input_select.select_option
|
||||
target: { entity_id: input_select.lounge_scene }
|
||||
data:
|
||||
option: "{{ scene_name }}"
|
||||
|
||||
# NEW: Wait briefly for HA to commit the new state (avoids race)
|
||||
- wait_template: "{{ states('input_select.lounge_scene') == scene_name }}"
|
||||
timeout: "00:00:02"
|
||||
continue_on_timeout: true
|
||||
|
||||
- service: script.lounge_apply_and_reset
|
||||
|
||||
lounge_apply_scene:
|
||||
alias: "Lounge: Apply current scene"
|
||||
mode: restart
|
||||
sequence:
|
||||
- variables:
|
||||
sel: "{{ states('input_select.lounge_scene') }}"
|
||||
#####################################################################
|
||||
# EXCLUDED SCENES (these are temp scenes, not remembered as last)
|
||||
#####################################################################
|
||||
excluded_scenes:
|
||||
- "Select Scene:"
|
||||
- "Reading On/Off"
|
||||
#- "Night Light"
|
||||
#####################################################################
|
||||
# SCENE SETTINGS (delta only - only list entities you want to change)
|
||||
#####################################################################
|
||||
scene_settings:
|
||||
Bright:
|
||||
light.esp_lounge6chdimmer_couch_spots_left: 00
|
||||
light.esp_lounge6chdimmer_couch_spots_right: 00
|
||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 100 # Centre Downlights (x6, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_downlights_south: 100 # South Downlights (x4, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 100 # Buttons in Rafters (x3, dimmable)
|
||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: "on" # North Downlights (x2 over stairs, non dimmable)
|
||||
light.esp_breakfastbarleds_breakfast_bar_leds: 90
|
||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 90
|
||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 90
|
||||
light.tasmo_h801_loungeled1_6180_a: 90
|
||||
light.tasmo_h801_loungeled1_6180_b: 90
|
||||
switch.lounge_cupboard_dual_usb_xus09_l2: on
|
||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: on # Back wall wallwasher Left
|
||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: on # Back wall wallwasher right
|
||||
switch.tasmo_ks811t_0702_lounge_3c: on # North Downlights (x2 over stairs, non dimmable)
|
||||
switch.esp_loungenorthswitch_relay_1_main_lights: on # Single switch to hallway relay output (Pelmet LEDs)
|
||||
|
||||
Movie:
|
||||
#light.esp_lounge6chdimmer_couch_spots_left: 40
|
||||
#light.esp_lounge6chdimmer_couch_spots_right: 40
|
||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 20 # Centre Downlights (x6, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_downlights_south: 20 # South Downlights (x4, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 20 # Buttons in Rafters (x3, dimmable)
|
||||
light.esp_breakfastbarleds_breakfast_bar_leds: 40
|
||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 40
|
||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 40
|
||||
light.tasmo_h801_loungeled1_6180_a: 60
|
||||
light.tasmo_h801_loungeled1_6180_b: 60
|
||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: off # North Downlights (x2 over stairs, non dimmable) switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
||||
switch.esp_loungenorthswitch_relay_1_main_lights: on # Single switch to hallway relay output (Pelmet LEDs)
|
||||
|
||||
Night Light:
|
||||
#light.esp_lounge6chdimmer_couch_spots_left: 40
|
||||
#light.esp_lounge6chdimmer_couch_spots_right: 40
|
||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 5 # Centre Downlights (x6, dimmable)
|
||||
#light.esp_lounge6chdimmer_lounge_downlights_south: 20 # South Downlights (x4, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 5 # Buttons in Rafters (x3, dimmable)
|
||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
||||
|
||||
Reading On/Off:
|
||||
light.esp_lounge6chdimmer_couch_spots_left: toggle_75
|
||||
light.esp_lounge6chdimmer_couch_spots_right: toggle_75
|
||||
#light.esp_lounge6chdimmer_dining_table_light: 60
|
||||
#light.esp_lounge6chdimmer_lounge_downlights_centre: 45
|
||||
#light.esp_lounge6chdimmer_lounge_downlights_south: 35
|
||||
#light.esp_lounge6chdimmer_lounge_rafter_buttons: 20
|
||||
#switch.tasmo_ks811t_0702_lounge_3c: on
|
||||
|
||||
Warm Cozy:
|
||||
light.esp_lounge6chdimmer_couch_spots_left: 30
|
||||
light.esp_lounge6chdimmer_couch_spots_right: 30
|
||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 15
|
||||
light.esp_breakfastbarleds_breakfast_bar_leds: 25
|
||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 30
|
||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 30
|
||||
light.tasmo_h801_loungeled1_6180_a: 25
|
||||
light.tasmo_h801_loungeled1_6180_b: 25
|
||||
switch.lounge_cupboard_dual_usb_xus09_l2: on
|
||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: on # Back wall wallwasher Left
|
||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: on # Back wall wallwasher right
|
||||
|
||||
TV General:
|
||||
light.esp_lounge6chdimmer_couch_spots_left: 50
|
||||
light.esp_lounge6chdimmer_couch_spots_right: 50
|
||||
#light.esp_lounge6chdimmer_dining_table_light: 100
|
||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 40 # Centre Downlights (x6, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_downlights_south: 40 # South Downlights (x4, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 40 # Buttons in Rafters (x3, dimmable)
|
||||
light.esp_breakfastbarleds_breakfast_bar_leds: 60
|
||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 60
|
||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 60
|
||||
light.tasmo_h801_loungeled1_6180_a: 60
|
||||
light.tasmo_h801_loungeled1_6180_b: 60
|
||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: off # North Downlights (x2 over stairs, non dimmable) switch.lounge_cupboard_dual_usb_xus09_l2: "on"
|
||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
||||
switch.esp_loungenorthswitch_relay_1_main_lights: on # Single switch to hallway relay output (Pelmet LEDs)
|
||||
|
||||
All Off:
|
||||
light.esp_lounge6chdimmer_couch_spots_left: 0
|
||||
light.esp_lounge6chdimmer_couch_spots_right: 0
|
||||
light.esp_lounge6chdimmer_dining_table_light: 0
|
||||
light.esp_lounge6chdimmer_lounge_downlights_centre: 0 # Centre Downlights (x6, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_downlights_south: 0 # South Downlights (x4, dimmable)
|
||||
light.esp_lounge6chdimmer_lounge_rafter_buttons: 0 # Buttons in Rafters (x3, dimmable)
|
||||
switch.esp_loungemiddleswitch_relay_3_downlights_north: "off" # North Downlights (x2 over stairs, non dimmable)
|
||||
light.esp_breakfastbarleds_breakfast_bar_leds: 0
|
||||
light.esp_loungecabinetleds2_lounge_cabinet_leds: 0
|
||||
light.esp_loungebookshelfleds_lounge_bookshelf_leds: 0
|
||||
light.tasmo_h801_loungeled1_6180_a: 0
|
||||
light.tasmo_h801_loungeled1_6180_b: 0
|
||||
switch.lounge_cupboard_dual_usb_xus09_l2: off
|
||||
switch.esp_loungesouthleftswitch_relay_1_wall_washer_left: off # Back wall wallwasher Left
|
||||
switch.esp_loungesouthrightswitch_relay_2_wall_washer_right: off # Back wall wallwasher right
|
||||
switch.esp_loungenorthswitch_relay_1_main_lights: off # Single switch to hallway relay output (Pelmet LEDs)
|
||||
|
||||
#####################################################################
|
||||
#####################################################################
|
||||
#####################################################################
|
||||
|
||||
# Only remember scenes that are not excluded
|
||||
- choose:
|
||||
- conditions: "{{ sel not in excluded_scenes }}"
|
||||
sequence:
|
||||
- service: input_text.set_value
|
||||
target: { entity_id: input_text.lounge_last_scene }
|
||||
data:
|
||||
value: "{{ sel }}"
|
||||
|
||||
- repeat:
|
||||
for_each: "{{ (scene_settings.get(sel, {})).keys() | list }}"
|
||||
sequence:
|
||||
- variables:
|
||||
ent: "{{ repeat.item }}"
|
||||
val: "{{ (scene_settings.get(sel, {}))[ent] }}"
|
||||
is_light: "{{ ent.startswith('light.') }}"
|
||||
is_switch: "{{ ent.startswith('switch.') }}"
|
||||
is_num: "{{ val is number }}"
|
||||
vstr: "{{ (val|string) if not is_num else '' }}"
|
||||
is_toggle: "{{ (not is_num) and (vstr|lower).startswith('toggle') }}"
|
||||
toggle_pct: "{{ (vstr.split('_')|last)|int if ('_' in vstr) else 100 }}"
|
||||
currently_on: "{{ is_state(ent, 'on') }}"
|
||||
|
||||
- choose:
|
||||
# 1) Lights: toggle[_NN] -> if on turn off, else turn on to NN (default 100)
|
||||
- conditions: "{{ is_light and is_toggle }}"
|
||||
sequence:
|
||||
- choose:
|
||||
- conditions: "{{ currently_on }}"
|
||||
sequence:
|
||||
- service: light.turn_off
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
default:
|
||||
- service: light.turn_on
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
brightness_pct: "{{ toggle_pct }}"
|
||||
|
||||
# 2) Switches: toggle -> flip state
|
||||
- conditions: "{{ is_switch and is_toggle }}"
|
||||
sequence:
|
||||
- service: switch.toggle
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
|
||||
# 3) Lights: numeric brightness (0 = off)
|
||||
- conditions: "{{ is_light and is_num and (val|int) > 0 }}"
|
||||
sequence:
|
||||
- service: light.turn_on
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
brightness_pct: "{{ val|int }}"
|
||||
- conditions: "{{ is_light and is_num and (val|int) == 0 }}"
|
||||
sequence:
|
||||
- service: light.turn_off
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
|
||||
# 4) Lights: textual/boolean on/off
|
||||
- conditions: "{{ is_light and not is_num and (val in [true, 'on', 'On', 'ON']) }}"
|
||||
sequence:
|
||||
- service: light.turn_on
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
- conditions: "{{ is_light and not is_num and (val in [false, 'off', 'Off', 'OFF']) }}"
|
||||
sequence:
|
||||
- service: light.turn_off
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
|
||||
# 5) Switches: textual/boolean on/off
|
||||
- conditions: "{{ is_switch and (val in [true, 'on', 'On', 'ON']) }}"
|
||||
sequence:
|
||||
- service: switch.turn_on
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
- conditions: "{{ is_switch and (val in [false, 'off', 'Off', 'OFF']) }}"
|
||||
sequence:
|
||||
- service: switch.turn_off
|
||||
data:
|
||||
entity_id: "{{ ent }}"
|
||||
|
||||
lounge_apply_and_reset:
|
||||
alias: "Lounge: Apply scene + reset selector"
|
||||
mode: restart
|
||||
sequence:
|
||||
- service: script.lounge_apply_scene
|
||||
- delay: "00:00:05"
|
||||
- service: input_select.select_option
|
||||
target: { entity_id: input_select.lounge_scene }
|
||||
data:
|
||||
option: "Select Scene:"
|
||||
|
||||
###############################################################################
|
||||
# AUTOMATIONS
|
||||
###############################################################################
|
||||
automation:
|
||||
- id: lounge_apply_on_selector_change
|
||||
alias: "Lounge - Apply when selector changes"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_select.lounge_scene
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: input_boolean.lounge_manual_override
|
||||
state: "off"
|
||||
- condition: template
|
||||
value_template: "{{ trigger.to_state.state != 'Select Scene:' }}"
|
||||
action:
|
||||
- service: script.turn_on
|
||||
target:
|
||||
entity_id: script.lounge_apply_and_reset
|
||||
|
||||
- id: lounge_tv_on_sets_tv_bias
|
||||
alias: "Lounge - TV on sets TV General (unless override)"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: remote.lounge_tv
|
||||
to: "on"
|
||||
for: "00:00:02" #small debounce
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: input_boolean.lounge_manual_override
|
||||
state: "off"
|
||||
- condition: template
|
||||
value_template: "{{ states('input_text.lounge_last_scene') != 'All Off' }}"
|
||||
action:
|
||||
- service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "TV General"
|
||||
|
||||
- id: lounge_tv_off_sets_bright
|
||||
alias: "Lounge - TV off sets Bright (unless override)"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: remote.lounge_tv
|
||||
to: "off"
|
||||
for: "00:00:02" #small debounce
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: input_boolean.lounge_manual_override
|
||||
state: "off"
|
||||
- condition: template
|
||||
value_template: "{{ states('input_text.lounge_last_scene') != 'All Off' }}"
|
||||
action:
|
||||
- service: script.lounge_set_scene
|
||||
data:
|
||||
scene_name: "Bright"
|
||||
Reference in New Issue
Block a user