I have some ceiling spekaers which has separate volume than my TV. Tv is connected with them via optic audio cable.
I want when I press on my tv’s remote volume up/down/mute, to be fast enough to setup those ceiling speakers.
Currently I have this automation which does work, but slow - I need to wait like 10 seconds to setup volume on my ceiling spekaers.
- alias: 'Sync volume bedroom speakers ceiling and tv'
mode: parallel
trigger:
- platform: state
entity_id: media_player.bedroom_tv, media_player.bedroom_ceiling_speaker
attribute: volume_level
condition:
condition: and
conditions:
- condition: state
entity_id: media_player.bedroom_tv
state: "on"
- condition: state
entity_id: "media_player.bedroom_ceiling_speaker"
state: "on"
action:
- variables:
vol_from: "{{ trigger.from_state.attributes.volume_level }}"
vol_to: "{{ trigger.to_state.attributes.volume_level }}"
- service: media_player.volume_set
data:
entity_id: media_player.bedroom_tv, media_player.bedroom_ceiling_speaker
volume_level: >
{% set volumes = state_attr('media_player.bedroom_tv', 'volume_level'),
state_attr('media_player.bedroom_ceiling_speaker', 'volume_level') %}
{% if vol_to|float > vol_from|float %}
{{ (volumes|max)|float }}
{% else %}
{{ (volumes|min)|float }}
{% endif %}