From 5eec41a43cd53df133b4f65cf8e23d9ac9759628 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Sun, 21 Dec 2025 14:30:41 -0800 Subject: [PATCH] Add button actions and presence reset blueprints - Add inovelli_button_actions blueprint for multi-tap controls - Double-tap up: brightness boost (+50%) - Double-tap down: return to adaptive lighting - Triple-tap up: max brightness (100%, 4000K) - Triple-tap down: night light (5%, warm red) - Configurable auto-reset timeout - Add presence_mode_reset blueprint for occupancy integration - Auto-reset manual control when room empty - Optional mode reset to default - Configurable empty delay - Multiple occupancy sensor support - Fix entity name in living room template (light.living_room_lights) --- .../automation/inovelli_button_actions.yaml | 163 ++++++++++++++++++ .../automation/presence_mode_reset.yaml | 117 +++++++++++++ ...daptive_lighting_living_room_template.yaml | 2 +- 3 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 blueprints/automation/inovelli_button_actions.yaml create mode 100644 blueprints/automation/presence_mode_reset.yaml diff --git a/blueprints/automation/inovelli_button_actions.yaml b/blueprints/automation/inovelli_button_actions.yaml new file mode 100644 index 0000000..d4727a0 --- /dev/null +++ b/blueprints/automation/inovelli_button_actions.yaml @@ -0,0 +1,163 @@ +--- +# blueprints/automation/inovelli_button_actions.yaml +# +# Inovelli Button Actions for Adaptive Lighting +# +# Implements multi-tap actions: +# - Double tap up: Brightness boost (+50% from current AL setting) +# - Double tap down: Return to Adaptive Lighting control +# - Triple tap up: Maximum brightness (100%, neutral white) +# - Triple tap down: Night light mode (5%, warm red) +# +# Features: +# - Auto-reset after configurable timeout +# - Reads current AL settings for relative boost +# - Works with any Inovelli Blue Dimmer via Zigbee2MQTT +# +# Requirements: +# - Inovelli Blue Dimmer (VZM31-SN) with buttonDelay >= 500ms +# - Adaptive Lighting switch for the room +# - Light entities to control +# +# Reference: ADAPTIVE_LIGHTING_CONTROL_SYSTEM_DESIGN.md lines 308-421 + +blueprint: + name: Inovelli Button Actions for Adaptive Lighting + description: Multi-tap brightness controls with adaptive lighting integration + domain: automation + input: + switch_action_event: + name: Switch Action Event + description: Event entity that reports button presses (event.xxx_action) + selector: + entity: + domain: event + + adaptive_lighting_switch: + name: Adaptive Lighting Switch + description: The AL switch entity for this room + selector: + entity: + domain: switch + integration: adaptive_lighting + + target_lights: + name: Target Lights + description: Light entities to control + selector: + target: + entity: + domain: light + + auto_reset_minutes: + name: Auto-Reset Timeout (minutes) + description: Minutes before returning to AL after manual boost + default: 10 + selector: + number: + min: 0 + max: 120 + step: 5 + unit_of_measurement: minutes + +mode: restart +max_exceeded: silent + +trigger: + - platform: state + entity_id: !input switch_action_event + +condition: + - condition: template + value_template: >- + {{ + state_attr(trigger.entity_id, 'event_type') in + ['up_double', 'down_double', 'up_triple', 'down_triple'] + }} + +action: + - variables: + action: "{{ state_attr(trigger.entity_id, 'event_type') }}" + al_switch: !input adaptive_lighting_switch + lights: !input target_lights + reset_minutes: !input auto_reset_minutes + + - choose: + # ======================================================================== + # DOUBLE TAP UP - Brightness Boost + # ======================================================================== + - conditions: "{{ action == 'up_double' }}" + sequence: + - variables: + current_brightness: >- + {{ state_attr(al_switch, 'brightness_pct') | float(50) }} + boosted_brightness: "{{ [current_brightness + 50, 100] | min }}" + current_color_temp: >- + {{ state_attr(al_switch, 'color_temp_kelvin') | int(4000) }} + boosted_color_temp: >- + {{ [current_color_temp + 1000, 5500] | min }} + + - service: light.turn_on + target: "{{ lights }}" + data: + brightness_pct: "{{ boosted_brightness }}" + color_temp_kelvin: "{{ boosted_color_temp }}" + transition: 1 + + # Auto-reset after timeout + - delay: + minutes: "{{ reset_minutes }}" + - service: adaptive_lighting.set_manual_control + data: + entity_id: "{{ al_switch }}" + manual_control: false + + # ======================================================================== + # DOUBLE TAP DOWN - Return to AL + # ======================================================================== + - conditions: "{{ action == 'down_double' }}" + sequence: + - service: adaptive_lighting.set_manual_control + data: + entity_id: "{{ al_switch }}" + manual_control: false + + # ======================================================================== + # TRIPLE TAP UP - Max Brightness (Neutral White) + # ======================================================================== + - conditions: "{{ action == 'up_triple' }}" + sequence: + - service: light.turn_on + target: "{{ lights }}" + data: + brightness_pct: 100 + color_temp_kelvin: 4000 + transition: 0.5 + + # Auto-reset after timeout + - delay: + minutes: "{{ reset_minutes }}" + - service: adaptive_lighting.set_manual_control + data: + entity_id: "{{ al_switch }}" + manual_control: false + + # ======================================================================== + # TRIPLE TAP DOWN - Night Light + # ======================================================================== + - conditions: "{{ action == 'down_triple' }}" + sequence: + - service: light.turn_on + target: "{{ lights }}" + data: + brightness_pct: 5 + rgb_color: [255, 50, 0] + transition: 1 + + # Auto-reset after timeout + - delay: + minutes: "{{ reset_minutes }}" + - service: adaptive_lighting.set_manual_control + data: + entity_id: "{{ al_switch }}" + manual_control: false diff --git a/blueprints/automation/presence_mode_reset.yaml b/blueprints/automation/presence_mode_reset.yaml new file mode 100644 index 0000000..5870991 --- /dev/null +++ b/blueprints/automation/presence_mode_reset.yaml @@ -0,0 +1,117 @@ +--- +# blueprints/automation/presence_mode_reset.yaml +# +# Presence-Based Mode and Manual Control Reset +# +# Automatically resets lighting mode and clears manual control when room +# becomes unoccupied for a configurable duration. +# +# Use Cases: +# - Reset Theater mode to Adaptive when leaving living room +# - Clear manual brightness boosts when bedroom becomes empty +# - Return bathroom to normal AL after presence ends +# +# Requirements: +# - Binary sensor(s) for occupancy/presence detection +# - Adaptive Lighting switch (optional - for manual control reset) +# - Mode input_select (optional - for mode reset) +# +# Reference: ADAPTIVE_LIGHTING_CONTROL_SYSTEM_DESIGN.md lines 437-451, +# 709-719 + +blueprint: + name: Presence-Based Mode and Manual Control Reset + description: >- + Reset lighting modes and AL manual control when room becomes empty + domain: automation + input: + occupancy_sensors: + name: Occupancy Sensors + description: Binary sensor(s) that detect room occupancy + selector: + entity: + domain: binary_sensor + device_class: occupancy + multiple: true + + empty_delay: + name: Empty Delay + description: How long room must be empty before reset + default: 5 + selector: + number: + min: 0 + max: 60 + step: 1 + unit_of_measurement: minutes + + adaptive_lighting_switch: + name: Adaptive Lighting Switch (Optional) + description: AL switch to reset manual control. Leave empty to skip. + default: {} + selector: + entity: + domain: switch + integration: adaptive_lighting + + mode_input_select: + name: Mode Input Select (Optional) + description: Mode selector to reset to Adaptive. Leave empty to skip. + default: {} + selector: + entity: + domain: input_select + + default_mode: + name: Default Mode + description: Mode to reset to when room becomes empty + default: "Adaptive" + selector: + text: + +mode: restart + +trigger: + - platform: state + entity_id: !input occupancy_sensors + to: 'off' + for: + minutes: !input empty_delay + +condition: + # Ensure ALL sensors are off (room is truly empty) + - condition: template + value_template: >- + {{ + expand(occupancy_sensors) | + selectattr('state', 'eq', 'on') | + list | count == 0 + }} + +action: + - variables: + occupancy_sensors: !input occupancy_sensors + al_switch: !input adaptive_lighting_switch + mode_select: !input mode_input_select + default_mode: !input default_mode + + # Reset manual control if AL switch provided + - if: + - condition: template + value_template: "{{ al_switch not in [none, {}, ''] }}" + then: + - service: adaptive_lighting.set_manual_control + data: + entity_id: "{{ al_switch }}" + manual_control: false + + # Reset mode if input_select provided + - if: + - condition: template + value_template: "{{ mode_select not in [none, {}, ''] }}" + then: + - service: input_select.select_option + target: + entity_id: "{{ mode_select }}" + data: + option: "{{ default_mode }}" diff --git a/packages/adaptive_lighting_living_room_template.yaml b/packages/adaptive_lighting_living_room_template.yaml index dda7d0b..782b25a 100644 --- a/packages/adaptive_lighting_living_room_template.yaml +++ b/packages/adaptive_lighting_living_room_template.yaml @@ -112,7 +112,7 @@ automation: alias: "Living Room: Reset Mode to Adaptive When Off" trigger: - platform: state - entity_id: light.living_room # UPDATE THIS + entity_id: light.living_room_lights # UPDATE THIS to: 'off' action: - service: input_select.select_option