Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mikeknoop/d57eb82e0c03a0b72032134299a8ca30 to your computer and use it in GitHub Desktop.
Save mikeknoop/d57eb82e0c03a0b72032134299a8ca30 to your computer and use it in GitHub Desktop.
Home Assistant: Lutron Keypad Raise/Lower Buttons Control (for Shades/Thermostats/Actions) v1.2
blueprint:
name: Lutron Keypad Raise/Lower Buttons Control
description: |
## Lutron Keypad Raise/Lower Buttons Control (for Shades/Thermostats/Actions) v1.2
This blueprint enables you to run any Home Assistant action when the Raise or Lower buttons are pressed. It also supports a couple special behaviors for Shades (covers) and Thermostats (climate).
Inputs:
* The "Dimmer Raise" scene for your chosen keypad
* The "Dimmer Lower" scene for your chosen keypad
* (Optional) Target Shade or Thermostat to control
* (Optional) Raise action
* (Optional) Lower action
If target is a Shade (cover):
1. When physical raise/lower button is simply pressed and released, shade will raise/lower to max open/closed.
2. If physical button is held for more than 1 second, releasing will immediately stop shade.
If target is a Thermostat (climate):
1. When physical raise/lower button is simply pressed and released, temperature will raise/lower by 1 degree.
If target is not specified:
1. Will simply call the user-defined raise/lower actions
Note: in Lutron software, choose "lower/raise programmed device" for the keypad button type but do not actually select a device. Lutron will automatically create two scenes "Dimmer Raise" and "Dimmer Lower" for your keypad in HA.
domain: automation
homeassistant:
min_version: 2023.4.0
input:
raise_scene_entity_id:
name: Dimmer Raise keypad scene
selector:
entity:
domain:
- scene
lower_scene_entity_id:
name: Dimmer Lower keypad scene
selector:
entity:
domain:
- scene
target_entity_id:
name: (Optional) Target Shade or Thermostat to control
description: Set this to use this blueprint's built-in behavior for covers and climate.
default:
selector:
entity:
domain:
- cover
- climate
multiple: false
optional_raise_action:
name: (Optional) Raise action
default:
description: Action is always run if set. Required when no target set.
selector:
action:
optional_lower_action:
name: (Optional) Lower action
default:
description: Action is always run if set. Required when no target set.
selector:
action:
mode: queued
max_exceeded: silent
trigger_variables:
raise_scene_entity_id: !input raise_scene_entity_id
lower_scene_entity_id: !input lower_scene_entity_id
target_entity_id: !input target_entity_id
optional_raise_action: !input optional_raise_action
optional_lower_action: !input optional_lower_action
variables:
raise_scene_id: '{{ raise_scene_entity_id | replace(''scene.'', '''') }}'
lower_scene_id: '{{ lower_scene_entity_id | replace(''scene.'', '''') }}'
trigger:
- platform: event
event_type: lutron_event
event_data:
full_id: '{{ raise_scene_entity_id | replace(''scene.'', '''') }}'
- platform: event
event_type: lutron_event
event_data:
full_id: '{{ lower_scene_entity_id | replace(''scene.'', '''') }}'
action:
# handles shade behavior
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ ''cover.'' in target_entity_id }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''pressed'' }}'
- condition: template
value_template: '{{ trigger.event.data.full_id == raise_scene_id }}'
then:
- service: cover.open_cover
data: {}
target:
entity_id: '{{ target_entity_id }}'
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ ''cover.'' in target_entity_id }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''pressed'' }}'
- condition: template
value_template: '{{ trigger.event.data.full_id == lower_scene_id }}'
then:
- service: cover.close_cover
data: {}
target:
entity_id: '{{ target_entity_id }}'
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ ''cover.'' in target_entity_id }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''released'' }}'
- condition: template
value_template: '{{ now() - this.attributes.last_triggered > timedelta(milliseconds=1500) }}'
then:
- service: cover.stop_cover
data: {}
target:
entity_id: '{{ target_entity_id }}'
# handles climate behavior
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ ''climate.'' in target_entity_id }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''pressed'' }}'
- condition: template
value_template: '{{ trigger.event.data.full_id == raise_scene_id }}'
then:
- service: climate.set_temperature
data:
temperature: '{{ (state_attr(target_entity_id, ''temperature'')|round(0)) + 1 }}'
target:
entity_id: '{{ target_entity_id }}'
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ ''climate.'' in target_entity_id }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''pressed'' }}'
- condition: template
value_template: '{{ trigger.event.data.full_id == lower_scene_id }}'
then:
- service: climate.set_temperature
data:
temperature: '{{ (state_attr(target_entity_id, ''temperature'')|round(0)) - 1 }}'
target:
entity_id: '{{ target_entity_id }}'
# handles plain action behavior
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ optional_raise_action is not none }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''pressed'' }}'
- condition: template
value_template: '{{ trigger.event.data.full_id == raise_scene_id }}'
then: !input optional_raise_action
- if:
- condition: and
conditions:
- condition: template
value_template: '{{ optional_lower_action is not none }}'
- condition: template
value_template: '{{ trigger.event.data.action == ''pressed'' }}'
- condition: template
value_template: '{{ trigger.event.data.full_id == lower_scene_id }}'
then: !input optional_lower_action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment