various tidyups

This commit is contained in:
root
2025-12-21 20:55:54 +13:00
parent 416efa6bd3
commit 19a14e1d1b
54 changed files with 5932 additions and 502 deletions
+77 -59
View File
@@ -18,50 +18,44 @@
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
##########################################################################################
substitutions:
# Device Naming
# Device Custom Naming
device_name: "esp-centralstairs-bottom"
friendly_name: "Central Stair Lightswitch - Bottom (2)"
description_comment: "Central Stair Lightswitch - Bottom, using Zemismart KS-811 Double Push Button. Main Stair Lights (1), Stair Footer Lights (2)"
device_area: "" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
device_area: "Lounge" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
static_ip_address: !secret esp-centralstairs-bottom_ip
mqtt_device_name_1: "stair-mainlights"
mqtt_device_name_2: "stair-footerlights"
# I/O Naming
switch_1_name: "Main Stair Lights (Lower)" # Physical, but just the lower lights below the media cabinet
switch_2_name: "Stair Footer Lights" # virtual only, nothing connected to this output
#relay_1_name: "Garage Lights"
#button_1_name: "Power Button"
#relay_icon: "mdi:lightbulb-group"
# Project Naming
project_name: "Zemismart Technologies.KS-811 Double" # Project Details
project_version: "v3.7" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
project_version: "v2.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
# MQTT Controls
mqtt_command_main_topic: !secret mqtt_command_main_topic
mqtt_status_main_topic: !secret mqtt_status_main_topic
mqtt_command_topic_1: "${mqtt_command_main_topic}/${mqtt_device_name_1}"
mqtt_status_topic_1: "${mqtt_status_main_topic}/${mqtt_device_name_1}"
mqtt_command_topic_2: "${mqtt_command_main_topic}/${mqtt_device_name_2}"
mqtt_status_topic_2: "${mqtt_status_main_topic}/${mqtt_device_name_2}"
mqtt_command_ON: "ON"
mqtt_command_OFF: "OFF"
# Passwords & Secrets (unfortunately you can't use substitutions inside secrets names)
api_key: !secret esp-api_key
ota_pass: !secret esp-ota_pass
static_ip_address: !secret esp-centralstairs-bottom_ip
mqtt_command_main_topic: !secret mqtt_command_main_topic
mqtt_status_main_topic: !secret mqtt_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
# General Settings
log_level: "ERROR" # 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_local_device_name: "stair-mainlights-lower"
mqtt_local_command_topic: "${mqtt_command_main_topic}/${mqtt_local_device_name}" # Topic we will use to command this locally without HA
mqtt_local_status_topic: "${mqtt_status_main_topic}/${mqtt_local_device_name}" # Topic we will use to view status locally without HA
mqtt_local_device_command_ON: "ON"
mqtt_local_device_command_OFF: "OFF"
# MQTT REMOTE Controls
mqtt_remote_device1_name: "stair-footerlights"
mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}"
mqtt_remote_device1_status_topic: "${mqtt_status_main_topic}/${mqtt_remote_device1_name}"
#mqtt_remote_device2_name: "stair-mainlights-upper"
#mqtt_remote_device2_command_topic: "${mqtt_local_command_main_topic}/${mqtt_remote_device2_name}/relay3/set"
#mqtt_remote_device2_status_topic: "${mqtt_local_status_main_topic}/${mqtt_remote_device2_name}/relay3/state"
mqtt_remote_device_command_ON: "ON"
mqtt_remote_device_command_OFF: "OFF"
# Switch Naming
switch_1_name: "Main Stair Lights (Lower)" # Physical, but just the lower lights below the media cabinet
switch_2_name: "Stair Footer Lights" # virtual only, nothing connected to this output
#switch_3_name: "Nil"
#########################################################################################
# PACKAGES: Included Common Packages
# https://esphome.io/components/packages.html
@@ -99,7 +93,7 @@ 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_debug: !include common/include_debug_diag_sensors.yaml
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
#########################################################################################
@@ -146,40 +140,64 @@ mqtt:
on_connect:
then:
- if:
# Status of relay 1, which has an actual light connected
condition:
lambda: 'return id(Relay_1).state;'
then:
- mqtt.publish:
topic: "${mqtt_local_status_topic}"
payload: "${mqtt_local_device_command_ON}"
topic: "${mqtt_status_topic_1}"
payload: "${mqtt_command_ON}"
qos: 0
retain: false
else:
- mqtt.publish:
topic: "${mqtt_local_status_topic}"
payload: "${mqtt_local_device_command_OFF}"
topic: "${mqtt_status_topic_1}"
payload: "${mqtt_command_OFF}"
qos: 0
retain: false
on_message:
# Light control to turn on relay 1
- topic: "${mqtt_local_command_topic}"
payload: "${mqtt_local_device_command_ON}"
# Relay 1: only turn ON if currently OFF
- topic: "${mqtt_command_topic_1}"
payload: "${mqtt_command_ON}"
then:
- switch.turn_on: Relay_1
# Light control to turn off relay 1
- topic: "${mqtt_local_command_topic}"
payload: "${mqtt_local_device_command_OFF}"
- if:
condition:
not:
- switch.is_on: Relay_1
then:
- switch.turn_on: Relay_1
# Relay 1: only turn OFF if currently ON
- topic: "${mqtt_command_topic_1}"
payload: "${mqtt_command_OFF}"
then:
- switch.turn_off: Relay_1
- topic: "${mqtt_remote_device1_status_topic}"
payload: "${mqtt_local_device_command_ON}"
- if:
condition:
- switch.is_on: Relay_1
then:
- switch.turn_off: Relay_1
# Relay 2: only turn ON if currently OFF
- topic: "${mqtt_command_topic_2}"
payload: "${mqtt_command_ON}"
then:
- switch.turn_on: Relay_2
# Light control to turn off relay 2
- topic: "${mqtt_remote_device1_status_topic}"
payload: "${mqtt_local_device_command_OFF}"
- if:
condition:
not:
- switch.is_on: Relay_2
then:
- switch.turn_on: Relay_2
# Relay 2: only turn OFF if currently ON
- topic: "${mqtt_command_topic_2}"
payload: "${mqtt_command_OFF}"
then:
- switch.turn_off: Relay_2
- if:
condition:
- switch.is_on: Relay_2
then:
- switch.turn_off: Relay_2
#########################################################################################
# STATUS LED
@@ -223,13 +241,13 @@ binary_sensor:
lambda: 'return id(Relay_2).state;'
then:
- mqtt.publish:
topic: "${mqtt_remote_device1_command_topic}"
payload: "${mqtt_remote_device_command_OFF}"
topic: "${mqtt_command_topic_2}"
payload: "${mqtt_command_OFF}"
retain: false
else:
- mqtt.publish:
topic: "${mqtt_remote_device1_command_topic}"
payload: "${mqtt_remote_device_command_ON}"
topic: "${mqtt_command_topic_2}"
payload: "${mqtt_command_ON}"
retain: false
#########################################################################################
@@ -243,13 +261,13 @@ switch:
id: Relay_1
on_turn_on:
- mqtt.publish:
topic: "${mqtt_local_status_topic}"
payload: "${mqtt_local_device_command_ON}"
topic: "${mqtt_status_topic_1}"
payload: "${mqtt_command_ON}"
retain: false
on_turn_off:
- mqtt.publish:
topic: "${mqtt_local_status_topic}"
payload: "${mqtt_local_device_command_OFF}"
topic: "${mqtt_status_topic_1}"
payload: "${mqtt_command_OFF}"
retain: false
- platform: gpio