Last active
May 24, 2022 13:14
-
-
Save WarriorRocker/f6a44fe4d69dcc2edec605fe67d03378 to your computer and use it in GitHub Desktop.
Revisions
-
WarriorRocker revised this gist
May 24, 2022 . 1 changed file with 41 additions and 55 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,27 @@ blueprint: name: ZHA - Philips Hue Dimmer Switch description: | Control lights with a Philips Hue Dimmer Switch. The top "on" button behaviour is adjustable. By default it behaves like this: - Press it while the light is off, and the light will turn on to the last set brightness. - Press it again while the light is on, the light will turn to the fixed brightness setting. Dim up/down buttons will change the brightness smoothly and can be pressed and hold until the brightness is satisfactory. The bottom "off" button will turn the light off. The "on" and "off" buttons can be assigned to an action when double or triple pressed. This allows you to assign e.g. a scene or something else. The minimum brightness setting will limit how low you can set the brightness. This will prevent dimming down until the light turns off. Set this to zero to disable this feature. domain: automation source_url: https://gist.github.com/WarriorRocker/f6a44fe4d69dcc2edec605fe67d03378 # Define the inputs for the blueprint input: remote: name: Philips Hue Dimmer Switch @@ -29,11 +36,12 @@ blueprint: light: name: Light(s) description: > The light entity to control (only a single entity is supported; use light groups when needed) selector: entity: domain: light force_brightness: name: Force turn on brightness @@ -68,11 +76,14 @@ blueprint: mode: restart max_exceeded: silent # Trigger the automation when the selected dimmer remote sends an event # Also only trigger on cluster_id 64512. This ignores the 'old' events with cluster_id 8. trigger: - platform: event event_type: zha_event event_data: device_id: !input 'remote' cluster_id: 64512 variables: light: !input 'light' @@ -83,103 +94,78 @@ variables: action: - variables: command: '{{ trigger.event.data.command }}' cur_brightness: '{{ state_attr(light, ''brightness'') | int }}' - choose: - conditions: '{{ command == ''on_press'' }}' sequence: - choose: - conditions: '{{ force_brightness }}' sequence: - service: light.turn_on data: entity_id: !input 'light' transition: 1 brightness: !input 'brightness' default: - service: light.turn_on data: entity_id: !input 'light' transition: 1 - conditions: '{{ command == ''off_press'' }}' sequence: - service: light.turn_off data: entity_id: !input 'light' transition: 1 - conditions: '{{ command == ''up_press'' }}' sequence: - service: light.turn_on data: entity_id: !input 'light' brightness_step: 25 transition: 1 - conditions: '{{ command == ''up_hold'' }}' sequence: - service: light.turn_on data: entity_id: !input 'light' brightness_step: 50 transition: 1 - conditions: '{{ command == ''down_press'' }}' sequence: - choose: - conditions: '{{ (cur_brightness - 25) >= min_brightness }}' sequence: - service: light.turn_on data: entity_id: !input 'light' transition: 1 brightness_step: -25 default: - service: light.turn_on data: entity_id: !input 'light' transition: 1 brightness: !input 'min_brightness' - conditions: '{{ command == ''down_hold'' }}' sequence: - choose: - conditions: '{{ (cur_brightness - 50) >= min_brightness }}' sequence: - service: light.turn_on data: entity_id: !input 'light' transition: 1 brightness_step: -50 default: - service: light.turn_on data: entity_id: !input 'light' transition: 1 brightness: !input 'min_brightness' -
WarriorRocker created this gist
Dec 28, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,185 @@ blueprint: name: ZHA - Philips Hue Dimmer Switch description: 'Control lights with a Philips Hue Dimmer Switch. The top "on" button will turn the lights on to the last set brightness (unless the force brightness is toggled on in the blueprint). Dim up/down buttons will change the brightness smoothly and can be pressed and hold until the brightness is satisfactory. The bottom "off" button will turn the lights off.' domain: automation input: remote: name: Philips Hue Dimmer Switch description: Pick either RWL020 (US) or RWL021 (EU) selector: device: integration: zha manufacturer: Philips entity: domain: sensor device_class: battery light: name: Light(s) description: The light(s) to control selector: target: entity: domain: light force_brightness: name: Force turn on brightness description: 'Force the brightness to the set level below, when the "on" button on the remote is pushed and lights turn on.' default: false selector: boolean: {} brightness: name: Brightness description: Brightness of the light(s) when turning on default: 255 selector: number: min: 0 max: 255 mode: slider step: 1 min_brightness: name: Min Brightness description: Minimum brightness of the light(s) when dimming default: 0 selector: number: min: 0 max: 255 mode: slider step: 1 mode: restart max_exceeded: silent trigger: - platform: event event_type: zha_event event_data: device_id: !input 'remote' variables: light: !input 'light' force_brightness: !input 'force_brightness' brightness: !input 'brightness' min_brightness: !input 'min_brightness' action: - variables: command: '{{ trigger.event.data.command }}' cluster_id: '{{ trigger.event.data.cluster_id }}' endpoint_id: '{{ trigger.event.data.endpoint_id }}' args: '{{ trigger.event.data.args }}' cur_brightness: '{{ state_attr(light.entity_id, ''brightness'') | int }}' - choose: - conditions: - '{{ command == ''on'' }}' - '{{ cluster_id == 6 }}' - '{{ endpoint_id == 1 }}' sequence: - choose: - conditions: '{{ force_brightness }}' sequence: - service: light.turn_on target: !input 'light' data: transition: 1 brightness: !input 'brightness' default: - service: light.turn_on target: !input 'light' data: transition: 1 - conditions: - '{{ command == ''off_with_effect'' }}' - '{{ cluster_id == 6 }}' - '{{ endpoint_id == 1 }}' - '{{ args == [0, 0] }}' sequence: - service: light.turn_off target: !input 'light' data: transition: 1 - conditions: - '{{ command == ''step'' }}' - '{{ cluster_id == 8 }}' - '{{ endpoint_id == 1 }}' - '{{ args == [0, 30, 9] }}' sequence: - service: light.turn_on target: !input 'light' data: brightness_step: 25 transition: 1 - conditions: - '{{ command == ''step'' }}' - '{{ cluster_id == 8 }}' - '{{ endpoint_id == 1 }}' - '{{ args == [0, 56, 9] }}' sequence: - service: light.turn_on target: !input 'light' data: brightness_step: 50 transition: 1 - conditions: - '{{ command == ''step'' }}' - '{{ cluster_id == 8 }}' - '{{ endpoint_id == 1 }}' - '{{ args == [1, 30, 9] }}' sequence: - choose: - conditions: '{{ (cur_brightness - 25) >= min_brightness }}' sequence: - service: light.turn_on target: !input 'light' data: transition: 1 brightness_step: -25 default: - service: light.turn_on target: !input 'light' data: transition: 1 brightness: !input 'min_brightness' - conditions: - '{{ command == ''step'' }}' - '{{ cluster_id == 8 }}' - '{{ endpoint_id == 1 }}' - '{{ args == [1, 56, 9] }}' sequence: - choose: - conditions: '{{ (cur_brightness - 50) >= min_brightness }}' sequence: - service: light.turn_on target: !input 'light' data: transition: 1 brightness_step: -50 default: - service: light.turn_on target: !input 'light' data: transition: 1 brightness: !input 'min_brightness'