I have set up an automation that is triggered by a group which includes my laptop’s camera and microphone.
The automation creates a scene on the fly (before_online_meeting) with the state of my office including lights, Spotify and Chromecast audio speakers
Once it has done that it pauses the media_players and sets lights to 100% brightness and I’m ready to start my meeting.
The same automation is triggered by the microphone and camera group again when they are switched off, but this time the automation attempts it turn on the scene created in the earlier run. Everything seems to work fine. Lights go on, music starts playing again.
However, there is some behaviour in Spotify which I can’t explain.
- It starts the song it was paused on playing from the start instead of resuming the song.
- Most importantly, the automation clears the Spotify queue. This has the effect that if am listening to a song in a playlist, it will start this song again after the meeting, however the music will stop after that song as the queue is empty.
Could someone explain what is happening here and help me optimise the automation so that Spotify’s queue isn’t cleared.
alias: meeting_toggles_office_music_lights
description: ''
trigger:
- platform: state
entity_id: group.meeting
from: 'off'
to: 'on'
id: start
for:
hours: 0
minutes: 0
seconds: 2
- platform: state
entity_id: group.meeting
id: stop
from: 'on'
to: 'off'
for:
hours: 0
minutes: 0
seconds: 5
condition:
- condition: zone
entity_id: person.name
zone: zone.home
action:
- choose:
- conditions:
- condition: trigger
id: start
sequence:
- service: scene.create
data:
scene_id: before_online_meeting
snapshot_entities:
- media_player.spotify_username
- media_player.office_speakers
- light.office_dimmer
- light.gallery_spots
- service: media_player.media_pause
target:
entity_id:
- media_player.spotify_username
- media_player.office_speakers
data: {}
- service: light.turn_on
data:
brightness_pct: 100
transition: 2
target:
entity_id:
- light.office_dimmer
- conditions:
- condition: trigger
id: stop
sequence:
- service: scene.turn_on
target:
entity_id: scene.before_online_meeting
data: {}
default: []
mode: single