diff --git a/esphome/esp-centralstairs-bottom.yaml b/esphome/esp-centralstairs-bottom.yaml index 3b8d493..0ec9d32 100644 --- a/esphome/esp-centralstairs-bottom.yaml +++ b/esphome/esp-centralstairs-bottom.yaml @@ -6,6 +6,7 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-centralstairs-bottom.yaml #:########################################################################################:# # VERSIONS: +# V3.8 2026-06-09 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 bottom of the central stairs -# - Button 1 toggles Relay 1 (Main Stair Lights - Lower) - physically connected +# - Button 1 single-click toggles Relay 1 (Main Stair Lights - Lower) - physically connected +# - Button 1 double-click toggles the Downstairs Lights Bulk Activation virtual switch for HA automations # - Button 2 controls Stair Footer Lights via MQTT (remote device), using Relay 2 as a local mirror state # - On MQTT connect, publishes current Relay 1 state to mqtt_status_topic_1 to keep remote status aligned #:########################################################################################:# @@ -27,19 +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 -# - Physical buttons still operate (Relay 1 local toggle; Button 2 publishes MQTT for footer lights) +# - Button 1 single-click continues to toggle Relay 1 locally +# - Button 1 double-click still toggles the local virtual switch, but HA automations will not act until HA returns +# - Button 2 continues to publish MQTT commands for footer lights # - Relay 1 state continues to be published to MQTT status topic # - HA entities are unavailable until HA returns # b) MQTT OFFLINE (but WiFi/Network and HA API ONLINE) # - Relay 1 still toggles locally and remains controllable from HA via API +# - Button 1 double-click can still toggle the virtual switch via HA API # - Button 2 cannot control footer lights (MQTT publish fails) # - Any MQTT state sync to remote devices will not occur while MQTT is down # c) Entire WiFi/Network OFFLINE -# - Physical button 1 continues to toggle Relay 1 locally (standalone) -# - Physical button 2 cannot control footer lights (no network transport) +# - Button 1 single-click continues to toggle Relay 1 locally (standalone) +# - Button 1 double-click can toggle the local virtual switch state, but HA will not see it until network returns +# - Button 2 cannot control footer lights (no network transport) # - Timeclocks will drift without network (SNTP). Time of day can be reset by powering off then on again at 12pm (midday) #:########################################################################################:# @@ -73,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 @@ -255,8 +265,25 @@ binary_sensor: - delayed_on: 30ms - delayed_off: 30ms name: "Button 1: ${switch_1_name}" - on_press: - - switch.toggle: Relay_1 + 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 + # Relay 1 single-click 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 local Relay 1. 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: + - switch.toggle: Relay_1 - platform: gpio pin: @@ -288,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