Hi All
Trying to get my Sonos working again
sonos.join
(before:media_player.sonos_join
)sonos.unjoin
(before:media_player.sonos_unjoin
)sonos.snapshot
(before:media_player.sonos_snapshot
)sonos.restore
(before:media_player.sonos_restore
)sonos.set_sleep_timer
(before:media_player.sonos_set_sleep_timer
)sonos.clear_sleep_timer
(before:media_player.sonos_clear_sleep_timer
)sonos.update_alarm
(before:media_player.sonos_update_alarm
)sonos.set_option
(before:media_player.sonos_set_option
)The last four of those services no longer target all entities by default since that is usually a mistake. The
entity_id
attribute is thus becoming mandatory for those services. If you really do want to target all you can useentity_id: all
.Next, YAML configuration of Sonos under the
media_player:
key is no longer accepted. While auto-configuration through the Integrations UI is now the preferred way, static configuration can still be specified under asonos:
key, for example:
My code was like this:
script:
# > SONOS TTS script to speak with text-to-speech
say:
alias: SONOS TTS
sequence:
- service: media_player.sonos_snapshot
data_template:
entity_id: "{{ 'media_player.' ~ where }}"
with_group: yes
- service: media_player.sonos_unjoin
data_template:
entity_id: "{{ 'media_player.' ~ where }}"
- service: media_player.volume_set
data_template:
entity_id: "{{ 'media_player.' ~ where }}"
volume_level: 0.45
- service: tts.google_say
data_template:
entity_id: "{{ 'media_player.' ~ where }}"
message: "{{ what }}"
language: 'da'
# Add a delay (default 1) in a length which you think fits best for all the things you want to say over TTS
- delay:
seconds: 1
- delay: >-
{% set duration = states.media_player[where].attributes.media_duration %}
{% if duration > 0 %}
{% set duration = duration - 1 %}
{% endif %}
{% set seconds = duration % 60 %}
{% set minutes = (duration / 60)|int % 60 %}
{% set hours = (duration / 3600)|int %}
{{ [hours, minutes, seconds]|join(':') }}
- service: media_player.sonos_restore
data_template:
entity_id: "{{ 'media_player.' ~ where }}"
with_group: yes
Announcement:
# Announce TTS input over Sonos
- alias: Announce TTS Input Over Sonos
hide_entity: true
trigger:
- platform: state
entity_id: input_text.announce_sonos
action:
- service: script.turn_on
entity_id: script.say
data_template:
variables:
# Remember to check that the sonos media_player name is correct below!
where: 'sonos_koekken'
what: "{{ states.input_text.announce_sonos.state }}"
TTS:
sonos_tts:
name: Sonos TTS
entities:
- input_text.announce_sonos
sonos:
name: Sonos
entities:
- media_player.sonos_sovevaerelse
- media_player.sonos_koekken
- media_player.sonos_victoria
- media_player.sonos_thomas
- media_player.sonos_stue
Is there a new way to do this?
Or would this still work if I can figure out what I need to substitute?
Best regards
Casperse