1
0

Add music button automations

This commit is contained in:
Przemek Grondek 2024-05-19 12:11:47 +02:00
parent 5d128eda69
commit f090e9c148
2 changed files with 90 additions and 0 deletions

View File

@ -35,6 +35,16 @@
name: Desk Lightbar
- entityId: light.office
name: Table lamp
- name: Build music button automations
delegate_to: localhost
template:
src: music-button.yaml.j2
dest: './build/automations/music.yaml'
vars:
room: Bathroom
room_id: bathroom
device_id: ea9059ad2df037a012ab01a575108dc5
player_entity_id: media_player.bathroom
- name: Include ZHA vars
include_vars:
file: zha-devices.yml

View File

@ -0,0 +1,80 @@
- 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 }}