After getting the gen2 sound remote this week, I played around with the blueprints from Atlantis_one (ZHA - Ikea Symfonisk sound controller GEN2 (the square one) with dot-button support for new firmware), James Crook, and Shawsky to try and get the most out of my automations.
Taking code from all three, I created this ZHA blueprint with the following features:
- Configurable volume step amount when doing single tap volume control
- Long press volume control support
- Dot and double dot button support (single tap, double tap, and long press)
blueprint:
name: ZHA - IKEA Symfonisk sound remote GEN2
description: Media control and shortcut button support for the IKEA Symfonisk sound remote GEN2.
domain: automation
source_url: https://community.home-assistant.io/t/zha-ikea-symfonisk-sound-remote-gen2-media-control-dot-buttons-volume-up-down-hold/673094
input:
remote:
name: Remote
description: IKEA Symfonisk controller GEN2 to use
selector:
device:
integration: zha
manufacturer: IKEA of Sweden
model: SYMFONISK sound remote gen2
multiple: false
media_player:
name: Media Player
description: The media player to control with this automation
selector:
entity:
domain: media_player
multiple: false
volume_steps:
name: Volume number of steps
description: Controls the volume scale. The default of 25 is the same scale as the Sonos app.
default: 25
selector:
number:
min: 5
max: 100
step: 5
unit_of_measurement: "Num"
mode: slider
single_dot_single_press:
name: Single dot (Single press)
description: Action to run on single dot press
default: []
selector:
action: {}
single_dot_double_press:
name: Single dot (Double press)
description: Action to run on single dot double press
default: []
selector:
action: {}
single_dot_long_press:
name: Single dot (Long press)
description: Action to run on single dot long press
default: []
selector:
action: {}
double_dot_single_press:
name: Double dot (Single press)
description: Action to run on double dot press
default: []
selector:
action: {}
double_dot_double_press:
name: Double dot (Double press)
description: Action to run on double dot double press
default: []
selector:
action: {}
double_dot_long_press:
name: Double dot (Long press)
description: Action to run on double dot long press
default: []
selector:
action: {}
mode: single
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
action:
- variables:
command: "{{ trigger.event.data.command }}"
cluster_id: "{{ trigger.event.data.cluster_id }}"
endpoint_id: "{{ trigger.event.data.endpoint_id }}"
args: "{{ trigger.event.data.args }}"
player: !input media_player
steps: !input volume_steps
stepsize: "{{ 1.0 / steps }}"
- choose:
#Play Pause
- conditions:
- "{{ command == 'toggle' }}"
- "{{ cluster_id == 6 }}"
- "{{ endpoint_id == 1 }}"
sequence:
- service: media_player.media_play_pause
target:
entity_id: "{{ player }}"
#Volume Up Press
- conditions:
- "{{ command == 'move_with_on_off' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
- "{{ trigger.event.data.params.move_mode == 0}}"
sequence:
- service: media_player.volume_set
target:
entity_id: "{{ player }}"
data:
volume_level: >-
{% set volume = state_attr(player, "volume_level") + stepsize %}
{{ 1.0 if volume > 1.0 else volume }}
#Volume Up Hold
- conditions:
- "{{ command == 'move' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
- "{{ trigger.event.data.params.move_mode == 0}}"
sequence:
- service: media_player.volume_up
target:
entity_id: "{{ player }}"
#Volume Down Press
- conditions:
- "{{ command == 'move_with_on_off' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
- "{{ trigger.event.data.params.move_mode == 1}}"
sequence:
- service: media_player.volume_set
target:
entity_id: "{{ player }}"
data:
volume_level: >-
{% set volume = state_attr(player, "volume_level") - stepsize %}
{{ 0.0 if volume < 0.0 else volume }}
#Volume Down Hold
- conditions:
- "{{ command == 'move' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
- "{{ trigger.event.data.params.move_mode == 1 }}"
sequence:
- service: media_player.volume_down
target:
entity_id: "{{ player }}"
#Next Track
- conditions:
- "{{ command == 'step' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
- "{{ trigger.event.data.params.step_mode == 0 }}"
sequence:
- service: media_player.media_next_track
target:
entity_id: "{{ player }}"
#Last Track
- conditions:
- "{{ command == 'step' }}"
- "{{ cluster_id == 8 }}"
- "{{ endpoint_id == 1 }}"
- "{{ trigger.event.data.params.step_mode == 1 }}"
sequence:
- service: media_player.media_previous_track
target:
entity_id: "{{ player }}"
#Single Dot Press
- conditions:
- "{{ command == 'short_release' }}"
- "{{ endpoint_id == 2 }}"
sequence: !input single_dot_single_press
#Single Dot Double Press
- conditions:
- "{{ command == 'multi_press_complete' }}"
- "{{ endpoint_id == 2 }}"
sequence: !input single_dot_double_press
#Single Dot Long Press
- conditions:
- "{{ command == 'long_press' }}"
- "{{ endpoint_id == 2 }}"
sequence: !input single_dot_long_press
#Double Dot Press
- conditions:
- "{{ command == 'short_release' }}"
- "{{ endpoint_id == 3 }}"
sequence: !input double_dot_single_press
#Double Dot Double Press
- conditions:
- "{{ command == 'multi_press_complete' }}"
- "{{ endpoint_id == 3 }}"
sequence: !input double_dot_double_press
#Double Dot Long Press
- conditions:
- "{{ command == 'long_press' }}"
- "{{ endpoint_id == 3 }}"
sequence: !input double_dot_long_press
This is my first time coding anything in Home Assistant ( I have only used the UI up till now) so hopefully it works as expected!
Thanks,
Dan