For context, I am using this automation with a Philips Hue Centris 2-Spot Ceiling Light in my office, which has individually controllable lights. However, this can be used with any set of more than one light e.g. a single ceiling light and a couple of table or floor lamps. The automation allows you to select the light that you are controlling and gives visual feedback by flashing it, so you know what is selected.
A double-click within three seconds of the last double-click will cycle through the lights that you can dim. If you double-click outside the three second period, it will simply flash the light that is selected to let you know which one you are about to control. A hold will switch it to scene selection, so that when you turn the knob it will cycle through the scenes of your choice in the order of your choosing and back in the opposite order if you turn the knob in the opposite direction. A double-click will switch it back to dimming mode and a single-click functions as a simple on/off toggle for the light selected by the double-click.
The idea here is to basically have a single dimmer for multiple lights, rather than needing to purchase multiple dimmers to control each light individually. I came up with the idea of adding scene scrolling after adding the multiple light dimming functions as I was trying to think of a use for the hold option. 
To use the automation you will need to create some Helpers:
- Office Dimmer Switch Double-Click |
input_datetime.office_dimmer_switch_double_click
| Date and Time | mdi:calendar-clock
- Office Dimmer Switch Hold |
input_datetime.office_dimmer_switch_hold
| Date and Time | mdi:calendar-clock
- Office Dimmer Switch Scene |
input_text.office_dimmer_switch_scene
| Text | Maximum Length 20 | mdi:panorama-outline
- Office Dimmer Switch Target |
input_text.office_dimmer_switch.target
| Text | Maximum Length 50 | mdi:target
Change the names to suit your lights and replace the entity_ids
in the automation. Icons are optional. I am just detailing them here, so you can reproduce it exactly if you want to. 
And here’s the automation:
# Office Dimmer Switch actions
- id: 56C46CA4-2F47-48AC-93AD-9DA17BBB2FB0
alias: "Buttons and Switches: Office Dimmer Switch actions"
mode: single
max_exceeded: silent # Do not warn in log if already running
trigger:
# Single-Click
- platform: state
entity_id: sensor.office_dimmer_switch_action
to: single
id: single_click
# Double-Click
- platform: state
entity_id: sensor.office_dimmer_switch_action
to: double
id: double_click
# Hold
- platform: state
entity_id: sensor.office_dimmer_switch_action
to: hold
id: hold
# Rotating
- platform: state
entity_id: sensor.office_dimmer_switch_action
to:
- start_rotating
- rotation
id: rotation
action:
- choose:
# Single-Click
- conditions:
- condition: trigger
id: single_click
sequence:
- service: light.toggle
target:
entity_id: "{{ states('input_text.office_dimmer_switch_target') }}"
# Double-Click
- conditions:
- condition: trigger
id: double_click
sequence:
- if:
# Check the last double-click was at least 3 seconds ago
- condition: template
value_template: "{{ as_timestamp(now()) - as_timestamp(states('input_datetime.office_dimmer_switch_double_click')) > 3 }}"
then:
# Flash the target lights
- service: light.toggle
target:
entity_id: "{{ states('input_text.office_dimmer_switch_target') }}"
data:
flash: short
else:
- choose:
# Office Ceiling Light to Office Ceiling Downlight
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_target
state: light.office_ceiling_light
sequence:
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_target
data:
value: light.office_ceiling_downlight
# Office Ceiling Downlight to Office Ceiling Spotlights
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_target
state: light.office_ceiling_downlight
sequence:
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_target
data:
value: light.office_ceiling_spotlights
# Office Ceiling Spotlights to Office Ceiling Light
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_target
state: light.office_ceiling_spotlights
sequence:
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_target
data:
value: light.office_ceiling_light
# Flash the target lights
- service: light.toggle
target:
entity_id: "{{ states('input_text.office_dimmer_switch_target') }}"
data:
flash: short
# Update the last double-click date and time
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.office_dimmer_switch_double_click
data:
timestamp: "{{ now().timestamp() }}"
# Hold
- conditions:
- condition: trigger
id: hold
sequence:
# Set the target lights
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_target
data:
value: light.office_ceiling_light
# Flash the target lights
- service: light.toggle
target:
entity_id: "{{ states('input_text.office_dimmer_switch_target') }}"
data:
flash: short
# Update the last hold date and time
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.office_dimmer_switch_hold
data:
timestamp: "{{ now().timestamp() }}"
# Rotation
- conditions:
- condition: trigger
id: rotation
sequence:
- if:
# Check the last hold was after the last double-click
- condition: template
value_template: "{{ (as_timestamp(states('input_datetime.office_dimmer_switch_hold')) - as_timestamp(states('input_datetime.office_dimmer_switch_double_click'))) > 0 }}"
then:
- if:
# Check the rotation angle is positive i.e. clockwise
- condition: template
value_template: "{{ trigger.to_state.attributes.action_rotation_angle | int > 0 }}"
then:
- choose:
# Off to Bright
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: 'Off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_bright
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Bright
# Bright to Concentrate
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Bright
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_concentrate
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Concentrate
# Concentrate to Relax
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Concentrate
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_relax
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Relax
# Relax to Dimmed
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Relax
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_dimmed
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Dimmed
# Dimmed to Nightlight
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Dimmed
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_nightlight
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Nightlight
# Nightlight to Off
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Nightlight
sequence:
- service: light.turn_off
target:
entity_id: light.office_ceiling_light
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: 'Off'
else:
- choose:
# Off to Nightlight
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: 'Off'
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_nightlight
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Nightlight
# Nightlight to Dimmed
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Nightlight
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_dimmed
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Dimmed
# Dimmed to Relax
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Dimmed
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_relax
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Relax
# Relax to Concentrate
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Relax
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_concentrate
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Concentrate
# Concentrate to Bright
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Concentrate
sequence:
- service: scene.turn_on
target:
entity_id: scene.office_ceiling_light_bright
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: Bright
# Bright to Off
- conditions:
- condition: state
entity_id: input_text.office_dimmer_switch_scene
state: Bright
sequence:
- service: light.turn_off
target:
entity_id: light.office_ceiling_light
- service: input_text.set_value
target:
entity_id: input_text.office_dimmer_switch_scene
data:
value: 'Off'
- delay: 00:00:01
else:
# Dim the light
- service: light.turn_on
target:
entity_id: "{{ states('input_text.office_dimmer_switch_target') }}"
data:
brightness_step_pct: >-
{%- if ((trigger.to_state.attributes.action_rotation_angle_speed | int / 24) | abs) < 1 -%}
{{ trigger.to_state.attributes.action_rotation_angle | int / 12 }}
{%- else -%}
{{ (trigger.to_state.attributes.action_rotation_angle | int / 12) * ((trigger.to_state.attributes.action_rotation_angle_speed | int / 24) | abs) }}
{%- endif -%}