Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mitch-mcfarlane/ca65c4ccb641f1f5d22567dc91284b62 to your computer and use it in GitHub Desktop.

Select an option

Save mitch-mcfarlane/ca65c4ccb641f1f5d22567dc91284b62 to your computer and use it in GitHub Desktop.
Blueprint for Lutron Aurora automations in ZHA. Toggles light on each button press
blueprint:
name: ZHA - Lutron Aurora (Incandescent Physics)
description: >
Control lights with a Lutron Aurora.
FEATURES:
- ROTARY: Simulates real Incandescent dimming physics. As you dim down, the light gets warmer.
- BUTTON: Toggles light (uses a fixed "functional" white temp).
bulb_type setting:
- RGB: Goes down to 1500K (Deep Orange/Red) using RGB blending.
- White Ambiance: Goes down to 2200K (Warm Glow) using standard white diodes.
domain: automation
input:
remote:
name: Lutron Aurora Dimmer Switch
description: The Lutron Aurora Z3-1BRL device.
selector:
device:
integration: zha
manufacturer: Lutron
model: Z3-1BRL
light:
name: Light(s) Target
description: The light(s) to control.
selector:
target:
entity:
domain: light
state_entity:
name: State Check Entity
description: Select ONE light (or group) to check if lights are currently On/Off.
selector:
entity:
domain: light
bulb_type:
name: Bulb Technology
description: >
Choose your bulb type to determine the dimming curve.
RGB allows deep red dimming (1500K). Standard limits to 2200K.
default: "rgb"
selector:
select:
options:
- label: "RGB (Deep Dimming - 1500K Floor)"
value: "rgb"
- label: "Standard White (Warm Glow - 2200K Floor)"
value: "white"
dim_to_off:
name: Enable Dim-to-Off
description: If enabled, turning the dial to the absolute minimum will turn the light OFF.
default: false
selector:
boolean: {}
button_kelvin:
name: Button Press Color (Kelvin)
description: Fixed color to use when turning ON via the Button (e.g., for working/cleaning).
default: 2700
selector:
number:
min: 2000
max: 6500
step: 100
mode: box
sensitivity:
name: Sensitivity
description: Lower sensitivity reduces the rate of Zigbee commands.
default: 3
selector:
number:
min: 1.0
max: 3.0
mode: slider
step: 1.0
mode: restart
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
action:
- variables:
# --- INPUTS ---
sensitivity_input: !input 'sensitivity'
selected_light: !input 'light'
state_entity: !input 'state_entity'
bulb_type: !input 'bulb_type'
button_k: !input 'button_kelvin'
dim_to_off_enabled: !input 'dim_to_off'
# --- ZIGBEE DATA ---
command: '{{ trigger.event.data.command }}'
args: '{{ trigger.event.data.args }}'
sensitivity: "{% if sensitivity_input == 3 %}1{% elif sensitivity_input == 2 %}5{% else %}15{% endif %}"
# --- BRIGHTNESS CALCULATION ---
# Lutron sends 0-255 in args[0]. We adjust by sensitivity.
raw_brightness: '{{ args[0]|int }}'
brightness: '{{ (raw_brightness / (sensitivity|int) * (sensitivity|int)) | int }}'
# Calculate Percentage (0.0 to 1.0) for the math formula
b_pct: '{{ brightness / 255 }}'
presstype: '{{ args[1]|int }}'
is_light_on: "{{ is_state(state_entity, 'on') }}"
# --- DIM TO OFF LOGIC ---
# Check if feature is enabled and brightness is effectively 0 (Lutron often sends 2 as min)
should_turn_off: "{{ dim_to_off_enabled and brightness <= 5 }}"
# --- PHYSICS ENGINE: KELVIN CALCULATION ---
# Formula: Floor + (Range * (Brightness%)^2)
target_kelvin: >
{% if bulb_type == 'rgb' %}
{{ (1500 + 1200 * (b_pct ** 2)) | int }}
{% else %}
{{ (2200 + 500 * (b_pct ** 2)) | int }}
{% endif %}
# --- RGB EMULATION FOR DEEP DIMMING ---
# If target is < 2000K and we are in RGB mode, calculate RGB values
use_rgb_mode: "{{ bulb_type == 'rgb' and target_kelvin < 2000 }}"
# Interpolate RGB: 1500K is roughly [255, 109, 0], 2000K is roughly [255, 147, 44]
deep_red_rgb: >
{% if use_rgb_mode %}
{% set r = 255 %}
{% set g = ((target_kelvin - 1500) * (147 - 109) / (2000 - 1500) + 109) | int %}
{% set b = ((target_kelvin - 1500) * (44 - 0) / (2000 - 1500) + 0) | int %}
[{{ r }}, {{ g }}, {{ b }}]
{% else %}
[0,0,0]
{% endif %}
- choose:
# --- ROTARY DIAL TURN (Presstype 2) ---
# This handles both Turning ON (if off) and Dimming (if on)
- conditions:
- '{{ command == ''move_to_level_with_on_off'' }}'
- '{{ presstype == 2 }}'
sequence:
- choose:
# OPTION 1: DIM TO OFF
- conditions: "{{ should_turn_off }}"
sequence:
- service: light.turn_off
target: '{{ selected_light }}'
data:
transition: 0.5
# OPTION 2: DEEP DIMMING (Low Kelvin RGB Simulation)
- conditions: "{{ use_rgb_mode }}"
sequence:
- service: light.turn_on
target: '{{ selected_light }}'
data:
brightness: '{{ brightness }}'
rgb_color: '{{ deep_red_rgb }}'
transition: 0.1
# OPTION 3: STANDARD DIMMING (White Diode CCT)
- conditions: "{{ not use_rgb_mode }}"
sequence:
- service: light.turn_on
target: '{{ selected_light }}'
data:
brightness: '{{ brightness }}'
color_temp_kelvin: '{{ target_kelvin }}'
transition: 0.1
# --- BUTTON PRESS (Presstype 7) ---
- conditions:
- '{{ command == ''move_to_level_with_on_off'' }}'
- '{{ presstype == 7 }}'
sequence:
- choose:
# If light is OFF -> Turn ON with FIXED Button Kelvin (Functional Light)
- conditions: "{{ not is_light_on }}"
sequence:
- service: light.turn_on
target: '{{ selected_light }}'
data:
color_temp_kelvin: '{{ button_k }}'
brightness_pct: 100
# If light is ON -> Turn OFF
- conditions: "{{ is_light_on }}"
sequence:
- service: light.turn_off
target: '{{ selected_light }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment