1
0
ansible-home-assistant/roles/automations/templates/music-button.yaml.j2

81 lines
3.1 KiB
Django/Jinja

- id: {{ room_id }}_music_button
alias: "[{{ room }}] Music button"
mode: single
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: {{ device_id }}
condition: [ ]
action:
- choose:
- conditions:
{% raw %}
- condition: template
value_template: "{{ trigger.event.data.command == 'toggle' }}"
- condition: template
value_template: "{{ trigger.event.data.cluster_id == 6 }}"
- condition: template
value_template: "{{ trigger.event.data.endpoint_id == 1 }}"
{% endraw %}
sequence:
- service: media_player.media_play_pause
target:
entity_id: {{ player_entity_id }}
- conditions:
{% raw %}
- condition: template
value_template: "{{ trigger.event.data.command == 'step' }}"
- condition: template
value_template: "{{ trigger.event.data.cluster_id == 8 }}"
- condition: template
value_template: "{{ trigger.event.data.endpoint_id == 1 }}"
- condition: template
value_template: "{{ trigger.event.data.params.step_mode == 0 }}"
{% endraw %}
sequence:
- service: media_player.media_next_track
entity_id: {{ player_entity_id }}
- conditions:
{% raw %}
- condition: template
value_template: "{{ trigger.event.data.command == 'step' }}"
- condition: template
value_template: "{{ trigger.event.data.cluster_id == 8 }}"
- condition: template
value_template: "{{ trigger.event.data.endpoint_id == 1 }}"
- condition: template
value_template: "{{ trigger.event.data.params.step_mode == 1 }}"
{% endraw %}
sequence:
- service: media_player.media_previous_track
entity_id: {{ player_entity_id }}
- conditions:
{% raw %}
- condition: template
value_template: "{{ trigger.event.data.command == 'move_with_on_off' }}"
- condition: template
value_template: "{{ trigger.event.data.cluster_id == 8 }}"
- condition: template
value_template: "{{ trigger.event.data.endpoint_id == 1 }}"
- condition: template
value_template: "{{ trigger.event.data.params.move_mode == 0}}"
{% endraw %}
sequence:
- service: media_player.volume_up
entity_id: {{ player_entity_id }}
- conditions:
{% raw %}
- condition: template
value_template: "{{ trigger.event.data.command == 'move_with_on_off' }}"
- condition: template
value_template: "{{ trigger.event.data.cluster_id == 8 }}"
- condition: template
value_template: "{{ trigger.event.data.endpoint_id == 1 }}"
- condition: template
value_template: "{{ trigger.event.data.params.move_mode == 1 }}"
{% endraw %}
sequence:
- service: media_player.volume_down
entity_id: {{ player_entity_id }}