How to play media on on Chromecast?

I’m trying to get a radio channel to automatically play on a Chromecast-enabled speaker in my kitchen. I can see that the automation is triggered and in the system log I can see that commands are sent to my speaker but it never starts playing.

  - alias: God morgon!
    initial_state: True
    hide_entity: False
    trigger:
      platform: state
      entity_id: binary_sensor.motion_hall
      from: 'off'
      to: 'on'
    action:
      service: media_player.play_media
      data:
        entity_id: media_player.sony_x77
        media_content_id: https://live-cdn.sr.se/pool2/p4malmo/p4malmo.isml/p4malmo.m3u8
        media_content_type: 'audio/mp4'
    condition:
      - condition: time
        after: '06:30:00'
        before: '09:30:00'
      - condition: state
        state: 'idle'
        entity_id: media_player.sony_x77

What am I missing here to get it to start playing?

1 Like

Maybe try ‘audio/mp3’?

Tried it but it didn’t help. If I open the URL in VLC, it says MPEG AAC Audio (mp4a). I tried audio/mp4a as well.

If I send a Text to speak (tts), that works fine.

This is what is printed in the main syslog. Nothing in home-assistant.log. Ps. this URL is not the same as I wrote above but it’s the same anyway…

Nov 20 21:18:24 mistik hass[31873]: #033[32m2017-11-20 21:18:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_call_id=139795903897160-173, domain=media_player, service_data=media_content_type=audio/mp4, entity_id=media_player.sony_x77, media_content_id=https://sverigesradio.se/topsy/direkt/srapi/207.hls?dvr_window_length=75, service=play_media>#033[0m
Nov 20 21:18:24 mistik hass[31873]: #033[32m2017-11-20 21:18:24 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.sony_x77, old_state=<state media_player.sony_x77=idle; media_duration=2.19175, media_position=0, app_id=CC1AD845, app_name=Default Media Receiver, supported_features=21437, volume_level=0.4000000059604645, friendly_name=Sony X77, media_content_id=https://sverigesradio.se/topsy/direkt/srapi/207.hls?dvr_window_length=75, media_position_updated_at=2017-11-20T21:17:55.195827+01:00, is_volume_muted=False @ 2017-11-20T21:17:04.196327+01:00>, new_state=<state media_player.sony_x77=idle; media_duration=2.19175, media_position=0, app_id=CC1AD845, app_name=Default Media Receiver, supported_features=21437, volume_level=0.4000000059604645, friendly_name=Sony X77, media_content_id=https://sverigesradio.se/topsy/direkt/srapi/207.hls?dvr_window_length=75, media_position_updated_at=2017-11-20T21:18:24.824578+01:00, is_volume_muted=False @ 2017-11-20T21:17:04.196327+01:00>>#033[0m

I take it you took out the condition to test it?

try it with a radio station that doesn’t use https as I suspect that’s what’s causing a problem?

To test it I just trigger it from the frontend, so the conditions don’t apply.

I changed to another http radio station I found via some random page that has a codec that looks the same in VLC (mp4a), and it works.

http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_qlmb_64.aac

So yes, it could very well be that it has a problem with HTTPS. But if I cast this radio channel from their app, this is the URL that I can see is playing when looking at the details on this receiver.

Any idea on how to proceed with this?

I’m sorry I know nothing about https :frowning:

According to Sveriges Radio (at the bottom of the page), the URL should be renamed to .mp3.

Try this URL instead: http://sverigesradio.se/topsy/direkt/207-hi.mp3

It works! Wonder why though, when I cast it from the app, the URL is m3u8 when it’s playing and you can see that it starts with …topsy…m3u. Thanks!

50