Visual Editor - If Conditions and Triggering Sonos


I want to have the Sonos Service resume play after a door bell is rang, but it needs to check before the doorbell rings that sonos was status = playing.

So I was going to do an if condition to check, but how do i log this status so i can check later before i call the service to resume?

Please post the automation(s) you are using so that we can offer suggestions that fit with the methods you are using.

How to Ask a Good Question #9

The idea would be:

  • Check to see if sonos is playing
  • Notify that the door was opened
  • Resume sonos only if it was originally playing

If i could set a variable or something if sonos is playing then i can check that later… just not sure if there is a way to do that…

alias: "Notification: Front Door"
description: ""
  - platform: state
      - binary_sensor.contact_sensor_2
    from: "off"
    to: "on"
condition: []
  - service: media_player.play_media
      entity_id: media_player.living_room
      media_content_id: media-source://tts/google_translate?message=Front+Door+Opened
      media_content_type: provider
      title: Front Door Opened
      media_class: app
      children_media_class: null
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: media-source://tts/google_translate?message=Front+Door+Opened
mode: restart

I understand why you want to do that but you should know it’s not necessary. If your automation uses sonos.snapshot and the media_player is not playing, using sonos.restore won’t cause any problems.

Thanks… didn’t know about the sonos snapshot but that takes care of it!