Hi all,
Here’s a blueprint to support controlling a media player with an Ikea Symfonisk Gen2 remote. It’s designed to work with the device added via Zigbee2MQTT (Z2M) only.
I wanted to allow for the use of more than one of these devices but also avoid the need to find and copy and paste topic strings from the entity MQTT settings. You can just select your device from the list
Hope you find it useful.
NOTE: It’s best to select “Legacy = False” in the specific settings for your controllers in the Z2M config.
Blueprint
blueprint:
# Media control via IKEA Symfonisk Gen2 - Shawsky April 2023 v1.55
# Updated April 2024 - Add additional filtering to prevent triggering from other devices/false positives. Thanks kenno.
# Updated April 2024 - Add support for device rename in upcoming Z2M release & allow legacy action for Play/Pause
# Updated September 2023 - Further updates for group/non grouped behaviour / fix issue for volume hold for grouped/non grouped. Allow 100 volume steps.
# Updated August 2023 - Resolve a volume issue for media players with no group_memeber attribute
# Updated June 2023 - Resolve filtering issue where multiple devices are in use
# Updated May 2023 - Add group volume control
# Volume changes partially based on https://gist.github.com/erkr/a437ebcb98a2b5ba2deebabd02f5ffae Eric Kreuwels
# and https://gist.github.com/alexwmaustin/2c25cfa1a0ade1ab9fc1ef0940289672 Alex Austin
name: Z2M - IKEA Symfonisk sound controller GEN2 for media
description:
'Control the selected media player (and any joined to it) with an IKEA Symfonisk sound controller GEN2 via Zigbee2MQTT (Z2M)
Supports single press on media buttons and single, double and long press for the "dot" buttons.'
domain: automation
input:
remote:
name: Remote
description: The IKEA Symfonisk controller GEN2 to use
selector:
device:
filter:
- integration: mqtt
manufacturer: IKEA
model: SYMFONISK sound remote gen2 (E2123)
- integration: mqtt
manufacturer: IKEA
model: SYMFONISK sound remote, gen 2 (E2123)
base_topic:
name: Zigbee2MQTT Base mqtt topic
description: The base topic configured in Zigbee2MQTT. If you haven't changed this, leave the default here ("zigbee2mqtt")
default: zigbee2mqtt
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:
name: Single Dot (Single)
description: Action to run on single dot press
default: []
selector:
action: {}
single_dot_double_press:
name: Single Dot (Double)
description: Action to run on single dot double press
default: []
selector:
action: {}
single_dot_long_press:
name: Single Dot (Long)
description: Action to run on single dot long press
default: []
selector:
action: {}
double_dot:
name: Double Dot (Single)
description: Action to run on double dot press
default: []
selector:
action: {}
double_dot_double_press:
name: Double Dot (Double)
description: Action to run on double dot double press
default: []
selector:
action: {}
double_dot_long_press:
name: Double Dot (Long)
description: Action to run on double dot long press
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
trigger_variables:
base_topic: !input base_topic
controller: !input remote
trigger:
- platform: mqtt
topic: "{{ base_topic }}/+/action"
condition:
- condition: template
value_template: "{{ trigger.topic == base_topic+'/'+device_attr(controller, 'name')+'/action' }} "
action:
- variables:
controllertopic: "{{ base_topic }}/{{ device_attr(controller, 'name') }}/action"
player: !input 'media_player'
steps: !input volume_steps
stepsize: '{{ 1.0 / steps }}'
- choose:
- conditions:
- "{{ trigger.payload != ''}}"
- "{{ trigger.topic == controllertopic }}"
sequence:
- choose:
## Commands
# Play / Pause
- conditions: "{{ trigger.payload == 'toggle' or trigger.payload == 'play_pause' }}"
sequence:
- service: media_player.media_play_pause
entity_id: !input 'media_player'
# Next Track
- conditions: "{{ trigger.payload == 'track_next' }}"
sequence:
- service: media_player.media_next_track
entity_id: !input 'media_player'
# Previous Track
- conditions: "{{ trigger.payload == 'track_previous' }}"
sequence:
- service: media_player.media_previous_track
entity_id: !input 'media_player'
## Volume for media players supporting groups
# Volume Up Press
- conditions: "{{ trigger.payload == 'volume_up' and state_attr(player, 'group_members') != none and state_attr(player, 'group_members') != [] }}"
sequence:
- repeat:
for_each: "{{ state_attr(player, 'group_members') }}"
sequence:
- service: media_player.volume_set
target:
entity_id: "{{ repeat.item }}"
data:
volume_level: >-
{% set volume = state_attr(repeat.item, "volume_level") + stepsize %}
{{ 1.0 if volume > 1.0 else volume }}
# Volume Down Press
- conditions: "{{ trigger.payload == 'volume_down' and state_attr(player, 'group_members') != none and state_attr(player, 'group_members') != [] }}"
sequence:
- repeat:
for_each: "{{ state_attr(player, 'group_members') }}"
sequence:
- service: media_player.volume_set
target:
entity_id: "{{ repeat.item }}"
data:
volume_level: >-
{% set volume = state_attr(repeat.item, "volume_level") - stepsize %}
{{ 0.0 if volume < 0.0 else volume }}
# Volume Up Hold
- conditions: "{{ trigger.payload == 'volume_up_hold' and state_attr(player, 'group_members') != none and state_attr(player, 'group_members') != [] }}"
sequence:
- repeat:
for_each: "{{ state_attr(player, 'group_members') }}"
sequence:
- service: media_player.volume_up
target:
entity_id: "{{ repeat.item }}"
# Volume Down Hold
- conditions: "{{ trigger.payload == 'volume_down_hold' and state_attr(player, 'group_members') != none and state_attr(player, 'group_members') != [] }}"
sequence:
- repeat:
for_each: "{{ state_attr(player, 'group_members') }}"
sequence:
- service: media_player.volume_down
target:
entity_id: "{{ repeat.item }}"
## Volume for media players not supporting groups
# Volume Up
- conditions: "{{ trigger.payload == 'volume_up' and (state_attr(player, 'group_members') == none or state_attr(player, 'group_members') == []) }}"
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 Down Press
- conditions: "{{ trigger.payload == 'volume_down' and (state_attr(player, 'group_members') == none or state_attr(player, 'group_members') == []) }}"
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 Up Hold
- conditions: "{{ trigger.payload == 'volume_up_hold' and (state_attr(player, 'group_members') == none or state_attr(player, 'group_members') == []) }}"
sequence:
- service: media_player.volume_up
target:
entity_id: "{{ player }}"
# Volume Down Hold
- conditions: "{{ trigger.payload == 'volume_down_hold' and (state_attr(player, 'group_members') == none or state_attr(player, 'group_members') == []) }}"
sequence:
- service: media_player.volume_down
target:
entity_id: "{{ player }}"
## Actions
# Single Dot Press
- conditions: "{{ trigger.payload == 'dots_1_short_release' }}"
sequence: !input single_dot
# Single Dot Double Press
- conditions: "{{ trigger.payload == 'dots_1_double_press' }}"
sequence: !input single_dot_double_press
# Single Dot Long Press
- conditions: "{{ trigger.payload == 'dots_1_long_press' }}"
sequence: !input single_dot_long_press
# Double Dot Press
- conditions: "{{ trigger.payload == 'dots_2_short_release' }}"
sequence: !input double_dot
# Double Dot Double Press
- conditions: "{{ trigger.payload == 'dots_2_double_press' }}"
sequence: !input double_dot_double_press
# Double Dot Long Press
- conditions: "{{ trigger.payload == 'dots_2_long_press' }}"
sequence: !input double_dot_long_press
Setup
Select your device, adjust your MQTT base topic if required, choose a media_player to control or a media_player that will act as the main device in a scenario where other players are grouped with it. Finally, configure the “dot” buttons as needed
Usage
- - Toggle Play / Pause
- - Previous Track
- - Next Track
- - Volume Up. Supports single press and hold
- - Volume Down. Supports single press and hold
- Single Dot - Supports single, double and long press to fire one or more actions
- Double Dot - Supports single, double and long press to fire one or more actions
Credits
Eric Kreuwels & Alex Austin for the original volume adjust aspects
Updates
2024-04-16 v1.55: Add additional filtering to remove the false positives of the automations triggering for MQTT topics or where you run multiple Ikea E2123 devices. This should help clean up log book entries etc. Thanks kenno.
2024-04-10 v1.54: Update device selector to account for the Ikea refactoring which will change the model name slightly. Both versions supported. Add support for the legacy action on the play/pause button.
2023-09-06 v1.52/v1.53: Update to allow 100 volume steps. / Fix copy paste fail on volume down hold for non grouped players.
2023-09-06 v1.51: Fix to stop non grouped players with empty group_members attribute triggering the grouped volume actions.
2023-09-05 v1.5: Resolve an issue with non grouped players presenting empty arrays rather than “none” in the group members attribute. Also apply these and previous fixes to volume hold.
2023-08-15 v1.4: Resolve an issue with volume not working on media player integrations that do not populate the group members attribute for single devices/group in a different way to the Sonos integration
2023-06-26 v1.3: Resolve an issue where multiple devices are attached to a system and all automations are triggered by any device.
2023-05-08 v1.2: Added support for volume control of all Sonos players joined to/grouped with the media player specified in the automation. The volume is adjusted on a per player basis so any differential set in the Sonos app is maintained. Note: To continue control the main media player specified in the automation must always remain in the Sonos group.
2023-04-16 v1.1: Tweak descriptive text for volume steps and set the default to match the scale of the Sonos app.