Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ondrejbaranek/b35749241651dfc6c9753b4ca610e86e to your computer and use it in GitHub Desktop.

Select an option

Save ondrejbaranek/b35749241651dfc6c9753b4ca610e86e to your computer and use it in GitHub Desktop.
blueprint:
name: Zigbee2MQTT - Philips Hue Dimmer (RWL020/021) - All Actions with Underscores
description: |
A comprehensive blueprint for the Philips Hue Dimmer Switch via Zigbee2MQTT. This version has been fully modified to use underscores in both the triggers and conditions.
Features configurable hold delay to distinguish between short presses and long holds.
Make sure that 'Elapsed' is enabled in the z2m advanced settings.
domain: automation
input:
remote:
name: Philips Hue Dimmer Switch
description: 'Select the Philips Hue Dimmer Switch device.'
selector:
device:
integration: mqtt
manufacturer: Philips
model: Hue dimmer switch
hold_delay:
name: Hold delay
description: If the button has been held more than the configured Hold delay, the corresponding held action is triggered.
default: 500
selector:
number:
min: 100.0
max: 1000.0
unit_of_measurement: milliseconds
mode: box
step: 10.0
button_on_short_press:
name: On button - Short Press
description: Action on button press.
default: []
selector:
action: {}
button_on_press_release:
name: On button - Press Release
description: Action on button release (after a short press).
default: []
selector:
action: {}
button_on_long_press:
name: On button - Long Press (Hold)
description: Action on button hold.
default: []
selector:
action: {}
button_on_hold_release:
name: On button - Hold Release
description: Action on button release (after a hold).
default: []
selector:
action: {}
button_up_short_press:
name: Brighten button - Short Press
description: Action on button press.
default: []
selector:
action: {}
button_up_press_release:
name: Brighten button - Press Release
description: Action on button release (after a short press).
default: []
selector:
action: {}
button_up_long_press:
name: Brighten button - Long Press (Hold)
description: Action on button hold.
default: []
selector:
action: {}
button_up_hold_release:
name: Brighten button - Hold Release
description: Action on button release (after a hold).
default: []
selector:
action: {}
button_down_short_press:
name: Dim button - Short Press
description: Action on button press.
default: []
selector:
action: {}
button_down_press_release:
name: Dim button - Press Release
description: Action on button release (after a short press).
default: []
selector:
action: {}
button_down_long_press:
name: Dim button - Long Press (Hold)
description: Action on button hold.
default: []
selector:
action: {}
button_down_hold_release:
name: Dim button - Hold Release
description: Action on button release (after a hold).
default: []
selector:
action: {}
button_off_short_press:
name: Off button - Short Press
description: Action on button press.
default: []
selector:
action: {}
button_off_press_release:
name: Off button - Press Release
description: Action on button release (after a short press).
default: []
selector:
action: {}
button_off_long_press:
name: Off button - Long Press (Hold)
description: Action on button hold.
default: []
selector:
action: {}
button_off_hold_release:
name: Off button - Hold Release
description: Action on button release (after a hold).
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
variables:
hold_delay: !input "hold_delay"
trigger:
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: on_press
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: on_press_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: on_hold
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: on_hold_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: up_press
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: up_press_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: up_hold
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: up_hold_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: down_press
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: down_press_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: down_hold
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: down_hold_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: off_press
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: off_press_release
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: off_hold
- platform: device
device_id: !input remote
domain: mqtt
type: action
subtype: off_hold_release
action:
- variables:
action: "{{ trigger.payload }}"
- choose:
# Hold actions - execute immediately, then delay
- conditions: "{{ action == 'on_hold' }}"
sequence:
- choose:
- conditions: "{{ true }}"
sequence: !input "button_on_long_press"
- delay:
milliseconds: !input "hold_delay"
- conditions: "{{ action == 'up_hold' }}"
sequence:
- choose:
- conditions: "{{ true }}"
sequence: !input "button_up_long_press"
- delay:
milliseconds: !input "hold_delay"
- conditions: "{{ action == 'down_hold' }}"
sequence:
- choose:
- conditions: "{{ true }}"
sequence: !input "button_down_long_press"
- delay:
milliseconds: !input "hold_delay"
- conditions: "{{ action == 'off_hold' }}"
sequence:
- choose:
- conditions: "{{ true }}"
sequence: !input "button_off_long_press"
- delay:
milliseconds: !input "hold_delay"
# Short press release actions - these will interrupt the delay above
- conditions: "{{ action == 'on_press_release' }}"
sequence: !input "button_on_short_press"
- conditions: "{{ action == 'up_press_release' }}"
sequence: !input "button_up_short_press"
- conditions: "{{ action == 'down_press_release' }}"
sequence: !input "button_down_short_press"
- conditions: "{{ action == 'off_press_release' }}"
sequence: !input "button_off_short_press"
# Hold release actions - triggered when button is released after long press
- conditions: "{{ action == 'on_hold_release' }}"
sequence: !input "button_on_hold_release"
- conditions: "{{ action == 'up_hold_release' }}"
sequence: !input "button_up_hold_release"
- conditions: "{{ action == 'down_hold_release' }}"
sequence: !input "button_down_hold_release"
- conditions: "{{ action == 'off_hold_release' }}"
sequence: !input "button_off_hold_release"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment