Thomas' writings, builds, toys

2020-05-09

Home Assistant Zigbee Media Remote

Ikeabutton

When I started working in my home office full-time during COVID-19 lockdown, I wanted a remote control to easily pause my music whenever a Teams call or meeting started.

I had an ikea 'hockeypuck' zigbee control laying around that could easily be commissioned onto my home assistant setup, which is controlling my Music Player Daemons.

The fact that it's a nice big button that can be easily tapped, makes this great as a music pause button!

The automations are quite lengthy, but for your information, I provide them here...

- alias: 'Ikeapuck MPD on'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'toggle'
  condition:
    - condition: state
      entity_id: media_player.mpd_zolder
      state: "off"
    - condition: template
      value_template: "{% if not is_state_attr('media_player.spotify_thomas_langewouters','source','Zolder')  %}true{% endif %}"
    - condition: template
      value_template: "{% if not is_state('media_player.spotify_thomas_langewouters', 'playing') %}true{% endif %}"
  action:
    service: media_player.turn_on
    data:
      entity_id: media_player.mpd_zolder

- alias: 'Ikeapuck spotify on'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'toggle'
  condition:
    - condition: state
      entity_id: media_player.mpd_zolder
      state: "off"
    - condition: template
      value_template: "{% if is_state_attr('media_player.spotify_thomas_langewouters','source','Zolder')  %}true{% endif %}"
    - condition: template
      value_template: "{% if is_state('media_player.spotify_thomas_langewouters', 'paused') %}true{% endif %}"
  action:
    service: media_player.media_play
    data:
      entity_id: media_player.spotify_thomas_langewouters

- alias: 'Ikeapuck MPD off'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'toggle'
  condition:
    - condition: state
      entity_id: media_player.mpd_zolder
      state: "playing"
  action:
    service: media_player.media_stop
    data:
      entity_id: media_player.mpd_zolder

- alias: 'Ikeapuck spotify off'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'toggle'
  condition:
  - condition: template
    value_template: "{% if is_state_attr('media_player.spotify_thomas_langewouters','source','Zolder')  %}true{% endif %}"
  - condition: template
    value_template: "{% if is_state('media_player.spotify_thomas_langewouters', 'playing') %}true{% endif %}"
  action:
    service: media_player.media_pause
    data:
      entity_id: media_player.spotify_thomas_langewouters

- alias: 'Ikeapuck vol up'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'brightness_up_click'
  action:
    service: media_player.volume_up
    data:
      entity_id: media_player.mpd_zolder


- alias: 'Ikeapuck vol down'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'brightness_down_click'
  action:
    service: media_player.volume_down
    data:
      entity_id: media_player.mpd_zolder

- alias: 'Ikeapuck spotify next'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'arrow_right_click'
  condition:
  - condition: template
    value_template: "{% if is_state_attr('media_player.spotify_thomas_langewouters','source','Zolder')  %}true{% endif %}"
  - condition: template
    value_template: "{% if is_state('media_player.spotify_thomas_langewouters', 'playing') %}true{% endif %}"
  action:
    service: media_player.media_next_track
    data:
      entity_id: media_player.spotify_thomas_langewouters

- alias: 'Ikeapuck spotify previous'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'arrow_left_click'
  condition:
  - condition: template
    value_template: "{% if is_state_attr('media_player.spotify_thomas_langewouters','source','Zolder')  %}true{% endif %}"
  - condition: template
    value_template: "{% if is_state('media_player.spotify_thomas_langewouters', 'playing') %}true{% endif %}"
  action:
    service: media_player.media_previous_track
    data:
      entity_id: media_player.spotify_thomas_langewouters

- alias: 'Ikeapuck mpd next'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'arrow_right_click'
  condition:
    - condition: state
      entity_id: media_player.mpd_zolder
      state: "playing"
  action:
    service: media_player.media_next_track
    data:
      entity_id: media_player.mpd_zolder

- alias: 'Ikeapuck mpd previous'
  trigger:
    - platform: state
      entity_id: sensor.ikeapuck_action
      to: 'arrow_left_click'
  condition:
    - condition: state
      entity_id: media_player.mpd_zolder
      state: "playing"
  action:
    service: media_player.media_previous_track
    data:
      entity_id: media_player.mpd_zolder