This the first blueprint I’ve written and I’m excited to share it with the community. I hope I’ve followed the steps correctly to share. Apologies in advance for any errors.
Context: None of the existing blueprints work with the native Hue integration in home assistant but are rather for ZHA or other zigbee integrations. I wanted to create one for the native Hue integration. Further this one uses the actual dial rotary values so that it feels more responsive to fast vs slow rotations.
Application: Use Hue Tap Dial Switch to control 1 speaker and 3 lights.
Use: Tap Once to select a device. Then the dial can be used to control brightness or volume of the device. Long press to toggle the device.
Requirements: A Hue Tap Dial switch, media player, and 3 lights. You will also need to create an input_text helper.
Credits: Credit to u/silashansen and u/Jannik_Wagner for inspiration and code examples. Credit to the community for helping me quickly get up to speed on templating.
https://gist.github.com/sundar2012/4b143d245b073d2f58bcb0c2aa2ecf5d
Full YAML below:
blueprint:
name: Philips Hue Tap Dial Audio + Light
description: Use the Philips Hue Tap Dial to control speakers and lights, volume and brightness. Long press to toggle play/pause on/off. Short press to select device for dial use.
domain: automation
input:
tap_dial:
name: Tap Dial
description: The tap dial to use. just select the battery sensor that is exposed
selector:
entity:
multiple: false
filter:
- domain: sensor
integration: hue
media_controller:
name: media player device for button 1
description: The media player for Button 1. Long Press will play/pause. Short press will allow you to control volume with the dial.
selector:
entity:
multiple: false
filter:
- domain:
- media_player
light_button2:
name: Light for button 2
description: The light for Button 2. Long Press will toggle the light. Short press will allow you to control brightness with the dial.
selector:
entity:
multiple: false
filter:
- domain:
- light
light_button3:
description: The light for Button 3. Long Press will toggle the light. Short press will allow you to control brightness with the dial.
selector:
entity:
multiple: false
filter:
- domain:
- light
light_button4:
name: Light for button 4
description: The light for Button 4. Long Press will toggle the light. Short press will allow you to control brightness with the dial.
selector:
entity:
multiple: false
filter:
- domain:
- light
helper_input:
name: helper input
description: You will need to create an input_text helper for this blueprint. Select it here.
selector:
entity:
multiple: false
filter:
- domain:
- input_text
variables:
tap_dial_used: !input tap_dial
controller: !input media_controller
light_button2: !input light_button2
light_button3: !input light_button3
light_button4: !input light_button4
helper_input: !input helper_input
mode: parallel
trigger:
- platform: event
event_type: hue_event
condition:
- condition: template
value_template: >-
{{trigger.event.data.device_id == device_id(tap_dial_used)}}
action:
- variables:
action: "{{ trigger.event.data.type }}"
action_sub: "{{ trigger.event.data.subtype }}"
action_steps: "{{ trigger.event.data.steps }}"
- choose:
- conditions:
- condition: template
value_template: "{{ action == 'short_release' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ action_sub == 1 }}"
sequence:
- service: input_text.set_value
metadata: {}
data:
value: !input media_controller
target:
entity_id: !input helper_input
- conditions:
- condition: template
value_template: "{{ action_sub == 2 }}"
sequence:
- service: input_text.set_value
metadata: {}
data:
value: !input light_button2
target:
entity_id: !input helper_input
- conditions:
- condition: template
value_template: "{{ action_sub == 3 }}"
sequence:
- service: input_text.set_value
metadata: {}
data:
value: !input light_button3
target:
entity_id: !input helper_input
- conditions:
- condition: template
value_template: "{{ action_sub == 4 }}"
sequence:
- service: input_text.set_value
metadata: {}
data:
value: !input light_button4
target:
entity_id: !input helper_input
- conditions:
- condition: template
value_template: "{{ action == 'long_press' }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ action_sub == 1 }}"
sequence:
- service: media_player.media_play_pause
metadata: {}
target:
entity_id: !input media_controller
data: {}
- conditions:
- condition: template
value_template: "{{ action_sub == 2 }}"
sequence:
- service: light.toggle
metadata: {}
target:
entity_id: !input light_button2
data: {}
- conditions:
- condition: template
value_template: "{{ action_sub == 3 }}"
sequence:
- service: light.toggle
metadata: {}
target:
entity_id: !input light_button3
data: {}
- conditions:
- condition: template
value_template: "{{ action_sub == 4 }}"
sequence:
- service: light.toggle
metadata: {}
target:
entity_id: !input light_button4
data: {}
- conditions:
- condition: template
value_template: "{{ action_sub == 'clock_wise' }}"
sequence:
- if:
- condition: template
value_template: "{{ states(helper_input)[:5] == 'media'}}"
then:
- service: media_player.volume_set
metadata: {}
data:
volume_level: >-
{{state_attr(states(helper_input),
'volume_level') + (trigger.event.data.steps / 1500)}}
target:
entity_id: !input media_controller
else:
- service: light.turn_on
metadata: {}
data:
brightness_step_pct: "{{ (trigger.event.data.steps / 1500)* 100 }}"
target:
entity_id: "{{ states(helper_input) }}"
- conditions:
- condition: template
value_template: "{{ action_sub == 'counter_clock_wise' }}"
sequence:
- if:
- condition: template
value_template: "{{ states(helper_input)[:5] == 'media'}}"
then:
- service: media_player.volume_set
metadata: {}
data:
volume_level: >-
{{state_attr(states(helper_input),
'volume_level') - (trigger.event.data.steps / 1500)}}
target:
entity_id: "{{ states(helper_input) }}"
else:
- service: light.turn_on
metadata: {}
data:
brightness_step_pct: "{{ (trigger.event.data.steps / 1500)* -100 }}"
target:
entity_id: "{{ states(helper_input) }}"
max: 15