Philips Hue dimmer switch + Zigbee2MQTT custom actions

Tags: #<Tag:0x00007fc40c026a20> #<Tag:0x00007fc40c0265e8>

This blueprint is for Hue Dimmer Switch (Philips 324131092621 control via MQTT | zigbee2mqtt.io) and Zigbee2MQTT. I found other blueprints that control just lights, but I wanted one that allows you to choose your own action (which can also be a control of light) for each of the following events: on-press, on-hold, up-press, up-hold, down-press, down-hold, off-press, off-hold.

My personal setup uses the button presses/holds to do amongst others the following: Ceiling lamp On/Off, All lights On/Off, Projector/Media Player play/pause, Some lamp toggle on hold etc.

github gist here & import button: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Zigbee2Mqtt Hue Dimmer Switch control
  description: ''
  domain: automation
  input:
    dimmer_action:
      name: Dimmer Switch Action sensor
      description: 'Select your "sensor.dimmer_action" entity that will control this automation.'
      selector:
        entity:
          domain: sensor
          integration: mqtt
    action_on_press:
      name: on-press
      description: select action to run when you press I
      selector:
        action:
    action_off_press:
      name: off-press
      description: select action to run when you press O
      selector:
        action:
    action_up_press:
      name: up-press
      description: select action to run when you press UP
      selector:
        action:
    action_down_press:
      name: down-press
      description: select action to run when you press DOWN
      selector:
        action:
    action_on_hold:
      name: on-hold
      description: select action to run when you hold I
      selector:
        action:
    action_off_hold:
      name: off-hold
      description: select action to run when you hold O
      selector:
        action:
    action_up_hold:
      name: up-hold
      description: select action to run when you hold UP
      selector:
        action:
    action_down_hold:
      name: down-hold
      description: select action to run when you hold DOWN
      selector:
        action:

trigger:
  - platform: state
    entity_id: !input dimmer_action
    attribute: action
    to: on-press
  - platform: state
    entity_id: !input dimmer_action
    attribute: action
    to: off-press
  - platform: state
    entity_id: !input dimmer_action
    attribute: action
    to: up-press
  - platform: state
    entity_id: !input dimmer_action
    attribute: action
    to: down-press
  - platform: state
    entity_id: !input dimmer_action
    to: up-hold
    attribute: action
  - platform: state
    entity_id: !input dimmer_action
    to: down-hold
    attribute: action
  - platform: state
    entity_id: !input dimmer_action
    to: on-hold
    attribute: action
  - platform: state
    entity_id: !input dimmer_action
    attribute: action
    to: off-hold
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: on-press
            attribute: action
        sequence:
          !input action_on_press
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: off-press
            attribute: action
        sequence:
          !input action_off_press
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: up-press
            attribute: action
        sequence:
          !input action_up_press
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: down-press
            attribute: action
        sequence:
          !input action_down_press
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: on-hold
            attribute: action
        sequence:
          !input action_on_hold
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: off-hold
            attribute: action
        sequence:
          !input action_off_hold
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: up-hold
            attribute: action
        sequence:
          !input action_up_hold
      - conditions:
          - condition: state
            entity_id: !input dimmer_action
            state: down-hold
            attribute: action
        sequence:
          !input action_down_hold
    default: []
mode: restart

You have to pick action for each event.If you don’t want to react to an event choose Delay of 0sec.

This is my very 1st blueprint, let me know how/if it does/doesn’t work for you :slight_smile:

I’ve updated the blueprint to utilize the new trigger id’s from HA 2021.7 + changed the way it reads the input.

If you disable Home Assistant legacy triggers in Z2M options this makes the sensor.dimmer_action disappear. The new version of the blueprint queries the Z2M mqtt topic directly and utilizes the new HA feature of trigger id’s to toggle actions.

Instead of sensor.dimmer_action entity the blueprint now asks for your MQTT Dimmer topic, which you can find here: Ha / configuration / devices / Your Dimmer MQTT device and click on the MQTT Info -

gist here & import button: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.(requires at least HA 2021.7)

blueprint:
  name: Zigbee2Mqtt Hue Dimmer Switch control v2
  description: ''
  domain: automation
  input:
    dimmer_action:
      name: Dimmer MQTT topic
      description: 'type in your Dimmer MQTT topic (i.e. zigbee2mqtt/Dimmer/action)'
      selector:
        text:
    action_on_press:
      name: on-press
      description: select action to run when you press I
      selector:
        action:
    action_off_press:
      name: off-press
      description: select action to run when you press O
      selector:
        action:
    action_up_press:
      name: up-press
      description: select action to run when you press UP
      selector:
        action:
    action_down_press:
      name: down-press
      description: select action to run when you press DOWN
      selector:
        action:
    action_on_hold:
      name: on-hold
      description: select action to run when you hold I
      selector:
        action:
    action_off_hold:
      name: off-hold
      description: select action to run when you hold O
      selector:
        action:
    action_up_hold:
      name: up-hold
      description: select action to run when you hold UP
      selector:
        action:
    action_down_hold:
      name: down-hold
      description: select action to run when you hold DOWN
      selector:
        action:

trigger:
  - platform: mqtt
    topic: !input dimmer_action
    payload: on-press
    id: dimmer_on
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_off
    payload: off-press
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_up
    payload: up-press
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_down
    payload: down-press
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_on_hold
    payload: on-hold
  - platform: mqtt
    topic: !input dimmer_action
    payload: off-hold
    id: dimmer_off_hold
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_up_hold
    payload: up-hold
  - platform: mqtt
    topic: !input dimmer_action
    payload: down-hold
    id: dimmer_down_hold

action:
  - choose:
      - conditions:
          - condition: trigger
            id: dimmer_on
        sequence:
          !input action_on_press
      - conditions:
          - condition: trigger
            id: dimmer_off
        sequence:
          !input action_off_press
      - conditions:
          - condition: trigger
            id: dimmer_up
        sequence:
          !input action_up_press
      - conditions:
          - condition: trigger
            id: dimmer_down          
        sequence:
          !input action_down_press
      - conditions:
          - condition: trigger
            id: dimmer_on_hold
        sequence:
          !input action_on_hold
      - conditions:
          - condition: trigger
            id: dimmer_off_hold
        sequence:
          !input action_off_hold
      - conditions:
          - condition: trigger
            id: dimmer_up_hold
        sequence:
          !input action_up_hold
      - conditions:
          - condition: trigger
            id: dimmer_down_hold
        sequence:
          !input action_down_hold
    default: []
mode: restart