Google Chromecast Media player automation fails to play

I have an automation which has been working fine since past 2 years. Nothing has been changed. However since past week it fails to play the mp3 and jut skips to the next step in the automation.

Has something changed?

data:
  media_content_id: >-
    /local/adhan/Mishary_Rashid_{{'Fajr_Adhan' if trigger.entity_id ==
    'sensor.fajr_prayer_offset' else 'Adhan'}}.mp3
  media_content_type: audio/mp3
target:
  entity_id:
    - media_player.basement_receiver
action: media_player.play_media

Any insights on this issue? The script worked flawlessly for past two years. I could change it but this script simplified a two path automation to just one.

Can you provide your logs so that we can try to help you better?

I checked traces and it shows the automation ran till the end. All steps are in fact executed and work perfectly… like turning on the media receiver outlet, waiting for a minute, muting the TV receiver if the TV is on. But the moment it reaches to play the mp3 it immediately skips it and traces show that if played and then it goes to the next step of checking to to see if the media receiver has completed playing and turned idle so that it can power off the media receiver.

Last night I completely removed the entire script and just used the gui to break it down into two steps. It ran fine when I ran it manually to play the media. Also tested in developer tools. But this morning it was exactly the same behavior. It just skipped or I would say executed the step and moved to the next step in less than a second.

Has there been some major Media Player breaking changes that may be causing this? I use the Google Chromecast to play the media. Manual play works but play in automation does not work.

Here is the simple default mp3 play code which works perfectly under developer tools.

action: media_player.play_media
metadata: {}
data:
  media_content_id: /local/adhan/Mishary_Rashid_Adhan.mp3
  media_content_type: audio/mp3
target:
  device_id: 4ede12472d406551b29add8c327f40f0

I have added the below code to configuration.yaml for logging…Will provide the updated logs.

logger:
  default: info
  logs:
    homeassistant.components.automation: debug
    homeassistant.components.cast: debug

I may have found the solution. My automation played the mp3 file now but will have to test it the next time the automation runs on the precise time.

I changed the media_content_type: from audio/mp3 to music

Not sure why it was working with audio/mp3 all these months and suddenly it woudn’t like that and changing to music works in the automation. What’s more confusing is that in developer tools audio/mp3 works and so does music but in automation audio/mp3 fails to play but changing to music works.

Same issue. Automation skipped the media play and went to the next step. Manual execution of the entire automation works which is even more confusing.

Basement Receiver
became unavailable

2:21:18 PM - 3 minutes ago

changed to Idle triggered by automation Adhan-test triggered by time set in Asr Prayer

2:20:58 PM - 4 minutes ago

turned off

2:20:33 PM - 4 minutes ago

became unavailable

12:50:25 PM - 2 hours ago

changed to Playing triggered by action Media player: Play media

12:50:04 PM - 2 hours ago - Admin

changed to Buffering triggered by action Media player: Play media

12:50:04 PM - 2 hours ago - Admin

changed to Idle triggered by action Media player: Play media

12:50:04 PM - 2 hours ago - Admin

turned off

12:49:10 PM - 2 hours ago

Which integration are you using for this automation. The info you’ve provided isn’t very helpful. The logs will tell us.

Go to Settings, System, Logs, then click on the down arrow in the top right corner. It will download the log file. Open it with a text editor like notepad or something similar.

Copy it, then paste here as a reply but be sure to type ``` before it and then again after it so it keeps the formatting.

I am waiting for the next trigger to execute in less than an hour and provide the logs.

@123 Just a gentle nudge. You had helped me last year fine tuning this same automation. Maybe you know what is causing this not to work suddenly with no change to the automation.

Here is my entire automation…

alias: Adhan-old
description: ""
triggers:
  - at:
      - sensor.fajr_prayer_offset
      - sensor.dhuhr_prayer_offset
      - sensor.asr_prayer_offset
      - sensor.maghrib_prayer_offset
      - sensor.isha_prayer_offset
    trigger: time
conditions: []
actions:
  - target:
      entity_id: switch.basement_receiver_outlet
    action: switch.turn_on
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 57
      milliseconds: 0
  - if:
      - condition: state
        entity_id: media_player.lg_webos_smart_tv
        state: "on"
    then:
      - parallel:
          - data:
              is_volume_muted: true
            target:
              entity_id:
                - media_player.marantz_sr8015
            action: media_player.volume_mute
          - data:
              media_content_id: >-
                /local/adhan/Mishary_Rashid_{{'Fajr_Adhan' if trigger.entity_id
                == 'sensor.fajr_prayer_offset' else 'Adhan'}}.mp3
              media_content_type: audio/mp3
            target:
              entity_id:
                - media_player.basement_receiver
            action: media_player.play_media
    else:
      - data:
          media_content_id: >-
            /local/adhan/Mishary_Rashid_{{'Fajr_Adhan' if trigger.entity_id ==
            'sensor.fajr_prayer_offset' else 'Adhan'}}.mp3
          media_content_type: audio/mp3
        target:
          entity_id:
            - media_player.basement_receiver
        action: media_player.play_media
  - wait_template: "{{ is_state('media_player.basement_receiver', 'idle') }}"
  - if:
      - condition: state
        entity_id: media_player.lg_webos_smart_tv
        state: "on"
    then:
      - parallel:
          - data:
              is_volume_muted: false
            target:
              entity_id:
                - media_player.marantz_sr8015
            action: media_player.volume_mute
          - type: turn_off
            device_id: 8566488152ea37da53e92aabe8c03b9e
            entity_id: switch.basement_receiver_outlet
            domain: switch
    else:
      - target:
          entity_id: switch.basement_receiver_outlet
        action: switch.turn_off
        data: {}
mode: single

@banstro, this might seem like a silly question, but do you have your local IP address documented in your config file?

homeassistant:
  internal_url: http://xxx.xxx.xxx.xxx:8123

I can run the mp3 straight from the browser providing the full path of HA. HA pickups the file and runs locally as well from /local as I tested it in Developer Tools.

The mp3 runs based on the trigger id which runs only on a specific template time sensor which updates once a day. I just ran the step removing the trigger in developer tools and it works… the mp3 plays. I am attaching the automation traces snapshot. You can see it run right through it till the very end. I will provide the logs in about 20 mins. The sensor.maghrib_prayer_offset will turn on at 4:40.

My automation worked! … I was skeptical but I added extra two tasks before playing the mp3. I added a task to “turn on” the google chromecast and add a 2 second wait … which was not needed prior… No changes to the original automation steps… just an extra task now added. Has to be something to do with HA and how it looks at the google chromecast.

  entity_id: media_player.basement_receiver
action: media_player.turn_on
data: {}

Great to hear! Cheers!