Skip to content

Instantly share code, notes, and snippets.

@Ultra9k
Last active May 23, 2022 13:45
Show Gist options
  • Save Ultra9k/2d21f4513715f877c9974b423503924d to your computer and use it in GitHub Desktop.
Save Ultra9k/2d21f4513715f877c9974b423503924d to your computer and use it in GitHub Desktop.
Philips_Hue_Dimmer_Switch_control.yaml
blueprint:
name: Philips Hue Dimmer Switch control
description: 'Control lights with a Philips Hue Dimmer Switch. Set an action for each button. Note: You have to pick an action for each event. If you don’t want to react to an event, choose a Delay of 0sec.'
domain: automation
input:
remote:
name: Dimmer Switch Action sensor
description: Select your entity that will control this
automation.
selector:
entity:
domain: sensor
action_on-press:
name: on-press
description: select action to run when you press I
default: []
selector:
action: {}
action_off-press:
name: off-press
description: select action to run when you press O
default: []
selector:
action: {}
action_up-press:
name: up-press
description: select action to run when you press UP
default: []
selector:
action: {}
action_down-press:
name: down-press
description: select action to run when you press DOWN
default: []
selector:
action: {}
action_on-hold:
name: on-hold
description: select action to run when you hold I
default: []
selector:
action: {}
action_off-hold:
name: off-hold
description: select action to run when you hold O
default: []
selector:
action: {}
action_up-hold:
name: up-hold
description: select action to run when you hold UP
default: []
selector:
action: {}
action_down-hold:
name: down-hold
description: select action to run when you hold DOWN
default: []
selector:
action: {}
mode: parallel
trigger:
- platform: state
entity_id: !input 'remote'
action:
- variables:
command: '{{ trigger.to_state.state }}'
- choose:
- conditions:
- '{{ command == ''on-press'' }}'
sequence: !input 'action_on-press'
- conditions:
- '{{ command == ''off-press'' }}'
sequence: !input 'action_off-press'
- conditions:
- '{{ command == ''up-press'' }}'
sequence: !input 'action_up-press'
- conditions:
- '{{ command == ''down-press'' }}'
sequence: !input 'action_down-press'
- conditions:
- '{{ command == ''on-hold'' }}'
sequence: !input 'action_on-hold'
- conditions:
- '{{ command == ''off-hold'' }}'
sequence: !input 'action_off-hold'
- conditions:
- '{{ command == ''up-hold'' }}'
sequence: !input 'action_up-hold'
- conditions:
- '{{ command == ''down-hold'' }}'
sequence: !input 'action_down-hold'
default: []
@lukoGit
Copy link

lukoGit commented Apr 2, 2022

Really? Why does mine work fine with trigger.to_state.attributes.action ?

no clue - I use the Philips Hue Dimmer Switch 929002398602 with firmware version 2.45.2_hF4400CA with zigbee2mqtt

Excerpt from my debug:
trigger: id: '0' idx: '0' platform: state entity_id: sensor.hue_switch from_state: entity_id: sensor.hue_switch state: attributes: icon: mdi:gesture-double-tap friendly_name: Hue Switch last_changed: '2022-04-02T20:02:47.253945+00:00' last_updated: '2022-04-02T20:02:47.253945+00:00' context: id: 20b77ca64a94dc6e001fd2ad29e6d733 parent_id: null user_id: null to_state: entity_id: sensor.hue_switch state: down_press attributes: icon: mdi:gesture-double-tap friendly_name: Hue Switch action last_changed: '2022-04-02T20:02:47.290489+00:00' last_updated: '2022-04-02T20:02:47.290489+00:00' context: id: efc17560d9b07a44882b74fb3ae0cac9 parent_id: null user_id: null
where you can see that it's not part of the attributes but a standalone state

@Ultra9k
Copy link
Author

Ultra9k commented Apr 2, 2022

Mine is Philips 324131092621 .

I will check if trigger.to_state.state also works with mine and I'll update the code if it does. Otherwise I'll maybe add a note about it in the description.

@lukoGit
Copy link

lukoGit commented Apr 2, 2022

Mine is Philips 324131092621 .

that certainly explains it - thanks for looking into it!

@Ultra9k
Copy link
Author

Ultra9k commented Apr 2, 2022

Both commands work with mine. So I'll update the code. Thanks for the feedback!

"device_class": null,
"disabled_by": null,
"disabled": false,
"entity_category": null,
"entity_id": "sensor.bedroom_remote_action",
"icon": null,
"original_device_class": null,
"original_icon": "mdi:gesture-double-tap",
"state": {
"entity_id": "sensor.bedroom_remote_action",
"state": "None",
"attributes": {
"action": null,

"action_duration": null,
"battery": 83,
"brightness": 223,
"counter": 1,
"linkquality": 191,
"update": {
"state": "idle"

@Soukyuu
Copy link

Soukyuu commented May 23, 2022

Thanks for the blueprint! I noticed a weird side-effect when using it to control a zigbee group of philips hue lights: the transaction time seems to somehow get overwritten for the off action. I have my lights set to fade to off in 1 second. This works from Lovelace and using another blueprint, but when using this blueprint, the lights turn off instantly instead - any ideas what might be causing it? I'm explicitly turning the group off, not setting a scene

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment