Philips Hue dimmer switch + Zigbee2MQTT custom actions

Unfortunately I found this automation quite buggy. It would require multiple presses to trigger the action, with a very high failure rate and sometimes it would take seconds to trigger it (same result with - and with _. For me it made no difference). I think the problem was it was quite cpu-intensive. I rewrote it for anyone interested to try it. At least for me it works flawlessly now.

EDIT: Just noticed I was using your V1. I didn’t try V2.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

gist here

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: restart
trigger:
- platform: state
  entity_id: !input 'remote'
action:
- variables:
    command: '{{ trigger.to_state.attributes.action }}'
- 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: []

I have a suggestion…
Rather than have the users put in delay: 00:00:00 in all the empties, why not put default: [] in every input and then only the ones they need be filed in.

It would be awesome if you could edit the top 2 posts and put that in there for everyone…

    action_on_hold:
      name: on-hold
      description: select action to run when you hold I
      default: []
      selector:
        action:

like that.

I think it has something to do with

device_options:
  legacy: false

With this setting, all my actions had underscores instead of dashes. I have now added legacy: true to the dimmer switch and the dashes are back :slight_smile:

If I’m completely honest, had I known about that when I made the blueprint. that’s absolutely how I’d do it, but seeing as this was the very 1st blueprint I made, I’m just happy it has been unfailingly working well enough for me since posting it without any change and as such I’m unlikely to improve it any further.

I am suggesting just peek in and edit it to add defaults, so that when new people pick up on it they don’t have an issue. Not suggesting you actually change the logic, just add the defaults.

It is still a very nice blueprint and an excellent design.

2 Likes

Thanks for the blueprint. I am also using it. Very happy.

I also just wanted to leave feedback that I had to change all the dashes in payload to underscores as well for it to work. I am running HA Core in a Docker Container with Zigbee2mqtt. My install is just a week old. So there is no legacy stuff at all anywhere.

For anyone who finds this blueprint and have issues.
The creator uses an older switch or has it set in legacy mode.

I forked the blueprint and put up a new version where I also incorporated the suggestion to add defaults.

1 Like

Thank you for mentioning this, I never figured out why was it that some ppl had - and some _, never thought of looking in zigbee2mqtt options for the device itself. I’m gonna leave the original version up because I’m lazy AF :grinning_face_with_smiling_eyes:

seriously…?
It took you longer to type this and provide all the support instead of just updating the first and second post.

Thanks for you work though!

1 Like

Hi, is there any way to use this blueprint to change color temperature of hue lights? I can no see any entity about color temperature.

anything light related can be done with service light.turn_on, just tick what you want to change and if the light is already on and you only tick temperature it will only change its temp

Slightly unrelated, but having it on ‘legacy off’ causes undesired behaviour for me where on-press action always triggers when holding the button, before on-hold action does, which is why I still have it on legacy in my own install. I opened a discussion at Z2M forum: hue dimmer behaviour change after changing "legacy" option · Koenkk/zigbee2mqtt · Discussion #17574 · GitHub

Well @C.G.B.Spender has done a fantastic job

But I moved over to switch manager

Far easier to keep track of switches visually

1 Like