MediaPlayer - No Last Christmas

It’s been a while since my last post, but as it’s that time of year again, I’d like to share a small automation with you.
The automation itself is still the quick-and-dirty version that has been running for a few years now. I have always wanted to refine it and share it with the community, but, as we all know, that refinement won’t happen any time soon.

What does the automation do?
As soon as a new song is played and has ‘last christmas’ in it’s title and the player is master, the song will be skipped.
For me, at least, this has helped to preserve some of my sanity during this time of year.
The condition if the player is master is SONOS specific, removing this should enable the automation also for other media players.

YAML
Just exchange ‘media_player.sonos_wohnzimmer’ with your player ID

alias: NoLastC - WZ
description: ""
triggers:
  - entity_id:
      - media_player.sonos_wohnzimmer
    attribute: media_title
    for:
      hours: 0
      minutes: 0
      seconds: 1
    trigger: state
conditions:
  - condition: template
    value_template: >-
      {{ 'last christmas' in state_attr('media_player.sonos_wohnzimmer',
      'media_title').lower()}}
  - condition: template
    value_template: >-
      {{ 'media_player.sonos_wohnzimmer' in
      state_attr('media_player.sonos_wohnzimmer', 'group_members')[0] }}
actions:
  - data: {}
    target:
      entity_id: media_player.sonos_wohnzimmer
    action: media_player.media_next_track
variables:
  MediaPlayer: media_player.sonos_wohnzimmer
mode: single
7 Likes

Thank you for making me smile :grinning:

Perfect.

However, why not trigger on this rather than every change in title?

Use the template trigger.

A life saver. Thanx

Because…

that refinement won’t happen any time soon.

As soon as it worked it was a fire and forget automation and if it works it ain’t stupid.

But I’m sure with the collective knowledge of the community there’s a chance that we end up having a optimized Multi-Device-Compatible Blueprint :laughing:

triggers:
  - trigger: template
    value_template: >
      {{ 'last christmas' in state_attr('media_player.sonos_wohnzimmer',
      'media_title').lower()}}
    for:
      hours: 0
      minutes: 0
      seconds: 1
conditions:
 - condition: template
    value_template: >
      {{ 'media_player.sonos_wohnzimmer' in
      state_attr('media_player.sonos_wohnzimmer', 'group_members')[0] }}
actions:
  - action: media_player.media_next_track
    data: {}
    target:
      entity_id: media_player.sonos_wohnzimmer
mode: single
1 Like

A RickRoll preventer? Can I set it up for some of the performers I do not particularly like to hear, mainly due to their foul mouthed lyrics?

@tom_l
Thanks - Just out of curiosity, performance wise it won’t make a real difference as the Automation is still triggered with every title change, just way more cleaner - or do I overlook something?

@IOT7712
Theoretically, every song can be skipped as long as the string to match is in the title. One thing I had in the back in my head since I’d created the automation was also to try to match against an array of multiple strings.

No, it is only triggered when the template is true.