Hi guys,
I want to create a script that will be playing spotify on multiple speakers in my house.
I almost succeeded but not enough.
I have two scripts, first script is a ‘main’ script and it sits on lovelace UI called:
Play spotify on multiple speakers
and I made input variables to it:
alias: Play spotify on multiple speakers
icon: "mdi:party-popper"
description: 'Play spotify on multiple speakers'
fields:
source_avr:
description: 'The avr zone/speaker that will reproduce sound'
example: media_player.avr_zone1, media_player.avr_zone2
source:
description: 'Selected source for ceiling zone speakers'
example: HEOS Music
volume_avr:
description: "sets the volume on the avr"
example: '0.6'
speakers:
description: 'Media player(s) that will be playing - ONLY IF ZONE2'
example: media_player.bedroom_ceiling_speaker, media_player.hallway_ceiling_speaker, media_player.bathroom_ceiling_speaker, media_player.office, media_player.office_shelf_speakers
volume_speaker:
description: "sets the volume on the speaker"
example: '0.52'
sequence:
#First, turn on and set up HEOS on Denon AVR
- service: script.turn_on
entity_id: script.set_avr
data:
variables:
avr_media_player: "{{ source_avr }}"
volume: "{{ volume_avr }}"
# Second, turn on all media_players (multiple zone speakers) and set the appropriete source
- service: media_player.turn_on
data:
entity_id: "{{ speakers }}"
- service: media_player.select_source
data:
entity_id: "{{ speakers }}"
source: "{{ source }}"
as you can see, I have a second inner
script called set_avr
which is turning my denon avr both zones (zone1 and zone 2), and there I have a bug. It turns both zones, firstly it turns zone1 with volume 0.5, then it runs zone2 with volume 0.5, but it sets volume for zone1 to 0
alias: Set AVR
icon: "mdi:party-popper"
description: 'Sets AVR to different zones and sources'
fields:
avr_media_player:
description: "gets the correct zone player for avr"
example: media_player.avr_zone1, media_player.avr_zone2
volume:
description: "sets the volume on the avr"
example: "0.4"
source:
description: 'Correct source for playing audio - amplifier sources - AUX1,AUX2,Blu-ray,Bluetooth,SBB BOX,CD,DVD,Game,HEOS Music,Media Player,TV Audio,Tuner'
example: HEOS Music
sequence:
# - choose:
# - conditions: "{{not is_state(avr_media_player,'on')}}"
# sequence:
- service: media_player.turn_on
data:
entity_id: "{{ avr_media_player }}"
# - wait_template: "{{ is_state(avr_media_player, 'on') }}"
- service: media_player.volume_set
data:
entity_id: "{{ avr_media_player }}"
volume_level: "{{ volume | float}}"
- service: media_player.select_source
data:
entity_id: "{{ avr_media_player }}"
source: "{{ source }}"
So, only that its left to figure it out, why does sets volume to 0 for zone1 when turns on zone2? In logs I have no errors or whatsoever.