Sonos leaving house and notification

Very new to HA and the community. I’m testing automations with Sonos. I’d like to stop Sonos with playing when I leave the house. I added a push-notification to test the automation. I added a condition so the automation will only run when a sonos speaker is playing.
Sonos does quit playing when I test this automation, however I keep receiving a push notification, also when Sonos is NOT playing. It looks like the condition is invalid. Anyone here to help a newbee out?

alias: Stop muziek bij vertrek
description: ''
trigger:
  - platform: state
    entity_id: device_tracker.iphone
    from: home
    to: not_home
condition:
  - condition: device
    device_id: ### 
    domain: media_player
    entity_id: media_player.eetkamer
    type: is_playing
action:
  - service: media_player.media_stop
    target:
      entity_id:
        - media_player.woonkamer
        - media_player.keuken
        - media_player.eetkamer
  - service: notify.mobile_app_iphone
    data:
      title: Sonos uitgeschakeld
      message: Sonos werd uitgeschakeld
mode: single

Have you tried breaking it down into two separate automations?

  • when iPhone leaves home, stop sonos
  • when sonos stops, send notification

Sometimes helps identify issues.

I also recommend doing this was @Stiltjack sais. It is very likely that your Condition stays the same.

You said

It looks like the condition is invalid. Anyone here to help a newbee out?.

What does your History say about the media_player.eetkamer?
grafik

My Ikea-Sonos Speakers for example always say that they are idle. I can Start-Stop, skip and even Pause then, but the State does never change.

grafik

I made a workaround and used my Spotify as condition… Maybe you have the same issue and this will also help you out?

grafik

With my Sonos speakers I use pause rather than stop and this does show up in History.

You could also try looking at the states tab in Developer Tools to see what’s going on.