Last active
December 28, 2023 23:16
-
-
Save creedda/a346d0c1ef3a883caeb7207e83ecf58c to your computer and use it in GitHub Desktop.
Sync Volume between two Media Players
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Synchronize Audio Volume | |
description: Synchronize the volume of 2 entities | |
domain: automation | |
input: | |
entity_1: | |
name: First entity | |
selector: | |
entity: {} | |
entity_2: | |
name: Second entity | |
selector: | |
entity: {} | |
source_url: https://gist.github.com/creedda/a346d0c1ef3a883caeb7207e83ecf58c | |
mode: restart | |
max_exceeded: silent | |
variables: | |
entity_1: !input entity_1 | |
entity_2: !input entity_2 | |
trigger: | |
- platform: state | |
entity_id: !input entity_1 | |
- platform: state | |
entity_id: !input entity_1 | |
attribute: is_volume_muted | |
- platform: state | |
entity_id: !input entity_1 | |
attribute: volume_level | |
- platform: state | |
entity_id: !input entity_2 | |
- platform: state | |
entity_id: !input entity_2 | |
attribute: is_volume_muted | |
- platform: state | |
entity_id: !input entity_2 | |
attribute: volume_level | |
condition: [] | |
action: | |
- choose: | |
- conditions: | |
condition: template | |
value_template: "{{ is_state(trigger.to_state.entity_id, 'on') }}" | |
sequence: | |
- service: media_player.volume_set | |
data: | |
volume_level: '{{ state_attr(trigger.to_state.entity_id, "volume_level") }}' | |
entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {% else %} {{ entity_1 }} {% endif %}' | |
- service: media_player.volume_mute | |
data: | |
is_volume_muted: '{{ state_attr(trigger.to_state.entity_id, "is_volume_muted") }}' | |
entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {% else %} {{ entity_1 }} {% endif %}' | |
default: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment