Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save krillerdk/000bac0f146ae83728b71a6bd797d03c to your computer and use it in GitHub Desktop.
Save krillerdk/000bac0f146ae83728b71a6bd797d03c to your computer and use it in GitHub Desktop.
Home Assistant Blueprints: ZHA version for controlling media players with an Ikea Symfonisk GEN2
blueprint:
# Added options to use the single and double dots buttons - both for single and double presses.
# Based on https://gist.github.com/erkr/a437ebcb98a2b5ba2deebabd02f5ffae Eric Kreuwels,
# https://gist.github.com/cooljimy84/f1f2da3a6b214879b82bf06a68d89264
# and https://gist.github.com/alexwmaustin/2c25cfa1a0ade1ab9fc1ef0940289672 by Alex Austin.
name: ZHA - IKEA Symfonisk sound controller GEN2 for media
description: 'Control media with an IKEA Symfonisk sound controller GEN2 (Square one)
Single press will toggle Play/Pause on your selected media player.'
domain: automation
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: Media player which will be controlled with this automation.
selector:
entity:
domain: media_player
multiple: false
volume_steps:
name: Volume number of steps
description: The number of steps for volume adjustments.
default: 10
selector:
number:
min: 5
max: 50
step: 5
unit_of_measurement: "Num"
mode: slider
single_dots:
name: Single Dots
description: Action to run on single dot button single press.
default: []
selector:
action: {}
double_dots:
name: Double Dots
description: Action to run on double dot button single press.
default: []
selector:
action: {}
single_dots_multipress:
name: Single Dots Double Press
description: Action to run on single dot button double press.
default: []
selector:
action: {}
double_dots_multipress:
name: Double Dots Double Press
description: Action to run on double dot button double press.
default: []
selector:
action: {}
mode: single
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
action:
- variables:
steps: !input volume_steps
stepsize: '{{ 1.0 / steps }}'
player: !input 'media_player'
command: '{{ trigger.event.data.command }}'
cluster_id: '{{ trigger.event.data.cluster_id }}'
endpoint_id: '{{ trigger.event.data.endpoint_id }}'
args: '{{ trigger.event.data.args }}'
- choose:
- conditions:
- '{{ command == ''toggle'' }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence:
- service: media_player.media_play_pause
entity_id: !input 'media_player'
- conditions:
- '{{ command == ''step'' }}'
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
- '{{ trigger.event.data.params.step_mode == 0 }}'
sequence:
- service: media_player.media_next_track
entity_id: !input 'media_player'
- conditions:
- '{{ command == ''step'' }}'
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
- '{{ trigger.event.data.params.step_mode == 1 }}'
sequence:
- service: media_player.media_previous_track
entity_id: !input 'media_player'
- conditions:
- '{{ command == ''short_release'' }}'
- '{{ cluster_id == 64640 }}'
- '{{ endpoint_id == 2 }}'
sequence: !input single_dots
- conditions:
- '{{ command == ''short_release'' }}'
- '{{ cluster_id == 64640 }}'
- '{{ endpoint_id == 3 }}'
sequence: !input double_dots
- conditions:
- '{{ command == ''multi_press_complete'' }}'
- '{{ cluster_id == 64640 }}'
- '{{ endpoint_id == 2 }}'
sequence: !input single_dots_multipress
- conditions:
- '{{ command == ''multi_press_complete'' }}'
- '{{ cluster_id == 64640 }}'
- '{{ endpoint_id == 3 }}'
sequence: !input double_dots_multipress
- 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
data:
volume_level: >-
{% set volume = state_attr(player, "volume_level") + stepsize %}
{{ 1.0 if volume > 1.0 else volume }}
entity_id: !input 'media_player'
- 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
data:
volume_level: >-
{% set volume = state_attr(player, "volume_level") - stepsize %}
{{ 0.0 if volume < 0.0 else volume }}
entity_id: !input 'media_player'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment