Forked from bjpetit/zha_lutron_aurora_blueprint.yaml
Last active
November 1, 2024 15:44
-
-
Save blizzrdof77/a0d048e58b8462748017e081bf3b9099 to your computer and use it in GitHub Desktop.
HASS Blueprint | ZHA - Lutron Aurora Smart Area with Night-Light Dimmer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: ZHA - Lutron Aurora Smart Area with Night-Light Dimmer (v3.0) | |
description: Control lights of a provided area with a Lutron Aurora Dimmer Pressing in the dimmer button will toggle between turning lights on to full brightness, and turning the lights off. Rotating the dimmer will increase and decrease the light brightness. Also supports late-night light groups. | |
domain: automation | |
source_url: https://gist.github.com/blizzrdof77/a0d048e58b8462748017e081bf3b9099 | |
input: | |
remote: | |
name: Lutron Aurora Dimmer Switch | |
description: Lutron Aurora Z3-1BRL | |
selector: | |
device: | |
integration: zha | |
manufacturer: Lutron | |
model: Z3-1BRL | |
entity: | |
domain: sensor | |
device_class: battery | |
areaid: | |
name: Area | |
description: The area to manage light control. | |
selector: | |
area: {} | |
circadian_mode: | |
name: Circadian Mode? | |
description: If selected, lights will dim to brightness and temperature based on the sun. | |
default: true | |
selector: | |
boolean: {} | |
extra_bright: | |
name: Increase Circadian Brightness? | |
description: Use extra-bright mode to increase circadian brightness value. | |
default: false | |
selector: | |
boolean: {} | |
sensitivity: | |
name: Sensitivity | |
description: Reducing sensitivity will reduce rate of changes being sent to lights | |
default: 3.00 | |
selector: | |
number: | |
min: 1.00 | |
max: 3.00 | |
step: 0.01 | |
mode: slider | |
transition: | |
name: Transition | |
description: Transition time in seconds | |
default: 1 | |
selector: | |
number: | |
min: 0.0 | |
max: 5.0 | |
step: 0.1 | |
mode: slider | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: event | |
event_type: zha_event | |
event_data: | |
device_id: !input 'remote' | |
action: | |
- variables: | |
sensitivity_input: !input 'sensitivity' | |
selected_area: !input 'areaid' | |
area_codename: '{{ (area_name(area_id(selected_area))|replace(" ", "_")|lower)|trim }}' | |
transition: !input 'transition' | |
sensitivity: "{{ sensitivity_input|float * sensitivity_input|float }}" | |
# brightness: '{{ (trigger.event.data.args[0]|int) / (sensitivity|int) * (sensitivity|int) }}' | |
circadian_mode: !input 'circadian_mode' | |
extra_bright: !input 'extra_bright' | |
command: '{{ trigger.event.data.command }}' | |
is_binary: '{{ ((trigger.event.data.args|last|int | default(0)) == 7) }}' | |
is_this_a_click: '{{ (trigger.event.data.args[1]|int) == 7 }}' | |
supports_circadian: >- | |
{%- set bright = (trigger.event.data.args[0]|int) -%} | |
{{ circadian_mode == true and is_binary == true and bright == 255 }} | |
circadian_brightness: >- | |
{%- set sensor_id = ('circadian_brightness_value' if extra_bright else 'circadian_brightness_alt_value') -%} | |
{{ states('sensor.' + sensor_id) }} | |
brightness: >- | |
{%- if supports_circadian == true -%} | |
{{ circadian_brightness }} | |
{%- else -%} | |
{%- set bright = (trigger.event.data.args[0]|int) -%} | |
{{ bright / (sensitivity|float) * (sensitivity|float) }} | |
{%- endif -%} | |
prior_brightness: '{{ brightness | default }}' | |
service_name: >- | |
{%- if supports_circadian == true -%} | |
{{ 'script.adjust_circadian_lighting' }} | |
{%- else -%} | |
{{ 'light.turn_on' }} | |
{%- endif -%} | |
night_light_group: >- | |
{%- set suffix = area_codename + '_night_lights' -%} | |
{%- if states.light[suffix].state is defined -%}{%- set d = 'light' -%}{%- else -%}{%- set d = 'group' -%}{%- endif -%} | |
{{ d + '.' + suffix }} | |
main_light_group: >- | |
{%- set suffix = area_codename + '_evening_lights' -%} | |
{%- if states.light[suffix].state is defined -%}{%- set d = 'light' -%}{%- else -%}{%- set d = 'group' -%}{%- endif -%} | |
{{ d + '.' + suffix }} | |
off_light_group: >- | |
{%- if is_state("binary_sensor.circadian_late_night_mode", "on") -%} | |
{{ main_light_group }} | |
{%- else -%} | |
{{ False }} | |
{%- endif -%} | |
target_light_group: >- | |
{%- if is_state(main_light_group, "on") -%} | |
{%- if (is_state("binary_sensor.circadian_late_night_mode", "on") or is_state(night_light_group, "on")) -%} | |
{%- set suffix = area_codename + '_lights' -%} | |
{%- if states.light[suffix].state is defined -%}{%- set d = 'light' -%}{%- else -%}{%- set d = 'group' -%}{%- endif -%} | |
{%- set light_entity = d + '.' + suffix -%} | |
{%- else -%} | |
{%- set light_entity = main_light_group -%} | |
{%- endif -%} | |
{%- else -%} | |
{%- if is_state("binary_sensor.circadian_late_night_mode", "on") -%} | |
{%- set light_entity = night_light_group -%} | |
{%- elif (is_state("binary_sensor.continue_circadian_sequence", "off") or is_state(night_light_group, "on")) -%} | |
{%- set suffix = area_codename + '_lights' -%} | |
{%- if states.light[suffix].state is defined -%}{%- set d = 'light' -%}{%- else -%}{%- set d = 'group' -%}{%- endif -%} | |
{%- set light_entity = d + '.' + suffix -%} | |
{%- else -%} | |
{%- set light_entity = main_light_group -%} | |
{%- endif -%} | |
{%- endif -%} | |
{{ light_entity }} | |
- choose: | |
- conditions: | |
- '{{ command == "move_to_level_with_on_off" }}' | |
- '{{ brightness != prior_brightness }}' | |
sequence: | |
- service: light.turn_on | |
data: | |
entity_id: '{{ target_light_group }}' | |
transition: '{{ transition }}' | |
brightness: >- | |
{%- if is_binary -%} | |
{%- if is_state(target_light_group, 'off') -%} | |
{{ circadian_brightness }} | |
{%- else -%} | |
{{ 0 }} | |
{%- endif -%} | |
{%- endif -%} | |
- choose: | |
- conditions: | |
- '{{ off_light_group != false }}' | |
- '{{ is_state(off_light_group, "on") }}' | |
sequence: | |
- service: light.turn_off | |
data: | |
entity_id: '{{ off_light_group }}' | |
- choose: | |
- conditions: | |
- '{{ (brightness|int) <= 1 }}' | |
- '{{ is_state(target_light_group, "on") }}' | |
sequence: | |
- service: light.turn_off | |
data: | |
transition: '{{ transition }}' | |
entity_id: '{{ target_light_group }}' | |
- conditions: | |
- '{{ (brightness|int) == 2 }}' | |
- '{{ is_state(target_light_group, "on") }}' | |
sequence: | |
- delay: 00:00:10 | |
- service: light.turn_off | |
data: | |
entity_id: '{{ target_light_group }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment