MQTT - Philips Hue Dimmer

Tags: #<Tag:0x00007f326ee4df98> #<Tag:0x00007f326ee4de30>

Inspired by ZHA - Philips Hue Dimmer Switch, but implemented for zigbee2mqtt

Control lights with a Philips Hue Dimmer Switch.

The top “on” button will turn the lights on to the last set
brightness.

Dim up/down buttons will change the brightness using predefined
step and can be pressed and hold until the brightness is
satisfactory.

The bottom “off” button will turn the lights off.

Long Off or On press will set brightness to the maximum or to the
minimum.

blueprint:
  name: MQTT - Philips Hue Dimmer
  description: 'Control lights with a Philips Hue Dimmer Switch.


    The top "on" button will turn the lights on to the last set
    brightness.


    Dim up/down buttons will change the brightness using predefined
    step and can be pressed and hold until the brightness is
    satisfactory.


    The bottom "off" button will turn the lights off.


    Long Off or On press will set brightness to the maximum or to the
    minimum.
    '
  domain: automation
  input:
    dimmer:
      name: Philips Hue dimmer action sensor
      description:
        'This must be an "action" sensor provided by zigbee2mqtt. For
        example "sensors.living_dimmer_action"
        '
      selector:
        entity:
          domain: sensor
    light:
      name: Target light
      selector:
        entity:
          domain: light
    step:
      name: Dimming step in percent
      default: 25
      selector:
        number:
          min: 0.0
          max: 50.0
          mode: slider
          step: 1.0
          unit_of_measurement: "%"
    lowest_brightness:
      name: Lowest brightness level
      description: 'Set this brightness level on long "Off" button press'
      default: 3
      selector:
        number:
          min: 1.0
          max: 50.0
          mode: slider
          step: 1.0
          unit_of_measurement: "%"
trigger:
  platform: state
  entity_id: !input dimmer
action:
  - variables:
      command: "{{ trigger.to_state.attributes.action }}"
      step: !input step
      negative_step: "{{ -1 * (step | int) }}"
  - choose:
    - conditions: "{{ command == 'on-press' }}"
      sequence:
        - service: light.turn_on
          data_template:
            entity_id: !input light
    - conditions: "{{ command == 'off-press' }}"
      sequence:
        - service: light.turn_off
          data_template:
            entity_id: !input light
    - conditions: "{{ command == 'down-press' or command == 'down-hold' }}"
      sequence:
        - service: light.turn_on
          data_template:
            entity_id: !input light
            brightness_step_pct: "{{ negative_step }}"
            transition: 1
    - conditions: "{{ command == 'up-press' or command == 'up-hold' }}"
      sequence:
        - service: light.turn_on
          data_template:
            entity_id: !input light
            brightness_step_pct: "{{ step }}"
            transition: 1
    - conditions: "{{ command == 'on-hold' }}"
      sequence:
        - service: light.turn_on
          data_template:
            entity_id: !input light
            brightness: 255
            transition: 1
    - conditions: "{{ command == 'off-hold' }}"
      sequence:
        - service: light.turn_on
          data_template:
            entity_id: !input light
            brightness_pct: !input lowest_brightness
            transition: 1
1 Like

Thanks a lot for the template, is that possible to control more than 1 light by the same remote? I have now create 2 same automation to achieve this. If it could be combined into one blueprint that will be perfect

Glad to hear my it is useful.
Yes it is possible, just add 2 or more lamps into a group.

I think you mean a Light Group and not a standard Group.

Lights in a standard group can only be turned on/off (you can’t control their brightness). In addition, the blueprint uses an Entity Selector filtered for light entities only, so it won’t display a Group for selection.

    light:
      name: Target light
      selector:
        entity:
          domain: light <------ Entity Selector for lights only.

Aaah, that’s why Alexa refuses to change brightness of my group. Other then that everything works (weird enough). I mean I can change brightness from Lovelace, and use the group in my blueprint. But (thanks to shitty Yeelight) I need to use this group via template

light: '{% if is_state(''binary_sensor.table_light_nightlight'', ''on'') %}
  group.living_nightlight {%- else %} group.living_light {% endif %}

  '

But template probably has nothing to do with the fact that it is working

Thank you, Yuri! I love these blueprints. Is there any chance you can add the possibility to change the color temperature with the Dimmer Switch like the default behavior of the Switch?

That is, if you continue to press the “On” button, you circulate between 4 different color temperatures.