additional esphome devices and fixes

This commit is contained in:
root
2026-04-28 18:50:15 +12:00
parent 15f348570f
commit f14bbbd23a
25 changed files with 1042 additions and 481 deletions
+53 -18
View File
@@ -6,6 +6,7 @@
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-centralstairs-top.yaml
#:########################################################################################:#
# VERSIONS:
# V3.8 2026-04-26 Added Downstairs Lights Bulk Activation virtual switch toggled by Button 1 double-click
# V3.7 2025-09-24 Upload to this device
# V3.5 2025-07-24 YAML tidyups
#:########################################################################################:#
@@ -15,7 +16,8 @@
#:########################################################################################:#
# OPERATION NOTES:
# - Light switch at top of the central stairs
# - Button 1 controls Main Stair Lights via MQTT (remote device), using Relay 1 as a local mirror state
# - Button 1 single-click controls Main Stair Lights via MQTT (remote device), using Relay 1 as a local mirror state
# - Button 1 double-click toggles the Downstairs Lights Bulk Activation virtual switch for HA automations
# - Button 2 toggles Relay 2 (Stair Footer Lights) - physically connected
# - On MQTT connect, publishes current Relay 2 state to mqtt_status_topic_2 to keep remote status aligned
#:########################################################################################:#
@@ -27,20 +29,27 @@
# Remote device 2 (Stair Footer Lights):
# - Command topic: ${mqtt_command_topic_2} -> ON,OFF
# - Status topic: ${mqtt_status_topic_2} -> ON,OFF
#
# HA virtual switch:
# - Downstairs Lights Bulk Activation is exposed as a virtual switch for Home Assistant automations
# - No custom MQTT command/status topic is defined for this virtual switch
#:########################################################################################:#
# OFFLINE NOTES:
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
# - Button 1 continues to publish MQTT commands for main stair lights
# - Button 1 single-click continues to publish MQTT commands for main stair lights
# - Button 1 double-click still toggles the local virtual switch, but HA automations will not act until HA returns
# - Button 2 continues to toggle Relay 2 locally
# - Relay 2 state continues to be published to mqtt_status_topic_2
# - HA entities are unavailable until HA returns
# b) MQTT OFFLINE (but WiFi/Network and HA API ONLINE)
# - Button 2 still toggles Relay 2 locally and is controllable via HA API
# - Button 1 cannot control main stair lights (MQTT publish fails)
# - Button 1 double-click can still toggle the virtual switch via HA API
# - Any MQTT state sync to remote devices will not occur while MQTT is down
# c) Entire WiFi/Network OFFLINE
# - Button 2 continues to toggle Relay 2 locally (standalone)
# - Button 1 cannot control main stair lights (no network transport)
# - Button 1 double-click can toggle the local virtual switch state, but HA will not see it until network returns
# - Timeclocks will drift without network (SNTP). Time of day can be reset by powering off then on again at 12pm (midday)
#:########################################################################################:#
@@ -74,7 +83,7 @@ substitutions:
# Project Naming
project_name: "Zemismart Technologies.KS-811 Double" # Project Details
project_version: "v2.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
project_version: "v2.1" # 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
@@ -256,21 +265,38 @@ binary_sensor:
- delayed_on: 30ms
- delayed_off: 30ms
name: "Button 1: ${switch_1_name}"
on_press:
# Toggle the remote Main Stair Lights via COMMAND topic, based on our mirrored state
- if:
condition:
lambda: 'return id(Relay_1).state;'
then:
- mqtt.publish:
topic: "${mqtt_command_topic_1}"
payload: "${mqtt_command_OFF}"
retain: false
else:
- mqtt.publish:
topic: "${mqtt_command_topic_1}"
payload: "${mqtt_command_ON}"
retain: false
on_multi_click:
# Double-click toggles a HA-visible virtual switch only. The double-click pattern is
# listed before the single-click pattern so a double-click does not also trigger the
# Main Stair Lights single-click MQTT action.
- timing:
- ON for at most 600ms
- OFF for at most 500ms
- ON for at most 600ms
- OFF for at least 150ms
then:
- switch.toggle: downstairs_lights_bulk_activation
# Single-click toggles the remote Main Stair Lights via COMMAND topic, based on our
# mirrored Relay 1 state. This now waits for the click sequence to finish so it can
# distinguish a single-click from a double-click.
- timing:
- ON for at most 600ms
- OFF for at least 500ms
then:
- if:
condition:
lambda: 'return id(Relay_1).state;'
then:
- mqtt.publish:
topic: "${mqtt_command_topic_1}"
payload: "${mqtt_command_OFF}"
retain: false
else:
- mqtt.publish:
topic: "${mqtt_command_topic_1}"
payload: "${mqtt_command_ON}"
retain: false
- platform: gpio
pin:
@@ -289,6 +315,15 @@ binary_sensor:
# https://esphome.io/components/switch/
#:########################################################################################:#
switch:
- platform: template
name: "Downstairs Lights Bulk Activation"
id: downstairs_lights_bulk_activation
icon: "mdi:lightbulb-group"
optimistic: true
restore_mode: ALWAYS_OFF
# HA automation helper only. Double-click Button 1 to toggle this switch on/off.
# It does not drive a relay directly and has no custom MQTT command/status topic.
- platform: gpio
name: "Relay 1: ${switch_1_name}"
pin: GPIO13