Audio switch, icecast chromecast devices

hello

ive succefully configure icecast/mopidy/chromecast devices to play audio. however my switch to turn the audio stream on/off toggles back to off automatically, the audio starts playing. However if toggling it again it doesnt stop the audio. I think in theory the switch should remain on while audio is playing and turn it off will stop the audio.

I have done a template switch to control this config below.

Any thoughts or input on this would be gratefully recieved…

switch:
- platform: template
  switches:
    icestream1:
      friendly_name: Living Room TV Audio
      value_template: "{{ is_state('media_player.living_room_tv', 'on') }}"
      turn_on:
        service: media_player.play_media
        entity_id: media_player.living_room_tv
        data:
          media_content_id: "http://192.168.5.232:8000/mopidy.mp3"
          media_content_type: "audio/mpeg"
      turn_off:
        service: media_player.turn_off
        entity_id: media_player.living_room_tv
    icestream2:
      friendly_name: Living Room Mini Audio
      value_template: "{{ is_state('media_player.living_room_speaker', 'on') }}"
      turn_on:
        service: media_player.play_media
        entity_id: media_player.living_room_speaker
        data:
          media_content_id: "http://192.168.5.232:8000/mopidy.mp3"
          media_content_type: "audio/mpeg"
      turn_off:
        service: media_player.turn_off
        entity_id: media_player.living_room_speaker
    icestream3:
      friendly_name: Front Room Audio
      value_template: "{{ is_state('media_player.living_room_speaker', 'on') }}"
      turn_on:
        service: media_player.play_media
        entity_id: media_player.family_room_speaker
        data:
          media_content_id: "http://192.168.5.232:8000/mopidy.mp3"
          media_content_type: "audio/mpeg"
      turn_off:
        service: media_player.turn_off
        entity_id: media_player.family_room_speaker

anybody any ideas?

Thanks

you must change ‘on’) with ‘playing’)

it is work for me.
I hope be hepful

thank you, not had time to look at it since posting the message. Thanks for repsonse, i will give it a try.

how did you run the icecast for exposing the mp3 url?
I enabled icecast in mopidy settings but when I try to access that url I can’t connect to it

you also have to setup Icecast of cause. - This helped me - Also you can setup to play a silent file fhile skipping to the next track that the CCA dont loose connection

    -->
    <hostname>127.0.0.1</hostname>

    <!-- You may have multiple <listener> elements -->
    <listen-socket>
        <port>8000</port>
        <!-- <bind-address>127.0.0.1</bind-address> -->
        <!-- <shoutcast-mount>/stream</shoutcast-mount> -->
    </listen-socket>
 
     <mount>
        <mount-name>/mopidy.mp3</mount-name>
        <fallback-mount>/1sec.mp3</fallback-mount>
        <fallback-override>1</fallback-override>
    </mount>

Hey @Underknowledge Could you possibly expand a bit more on this bit for me. I have icecast/mopidy all setup and working for the last year or so now, but has always annoyed me that it doesn’t continue streaming when you hit next track on MPD.

<mount>
    <mount-name>/mopidy.mp3</mount-name>
    <fallback-mount>/etc/icecast2/1sec.mp3</fallback-mount>
    <fallback-override>1</fallback-override>
</mount>

I have this added into my config, but still have the same problem with it stopping after trying to change tracks. The file is there in the path. Sure I am missing something easy, but any help is super appreciated.

I stumbled across it in the mopidy forum - Sadly I dont find the post atm.
here the config and the mp3 I use
icecast.xml (9.1 KB)
1sec.mp3.renametomp3.xml (19.9 KB)
mopidy.conf.yaml (3.2 KB)
and the docks on mopidy https://docs.mopidy.com/en/latest/audio/#fallback-stream
file needs to be placed in the directory defined by <webroot>...</webroot> in the Icecast configuration.
so my guess is icecast try to load /etc/icecast2//etc/icecast2/1sec.mp3 on your side

2 Likes

Told ya it was something easy, thats the bit I missed. I had it in the config directory, not web.

Works perfectly now, amazing. Wish I knew about this sooner.

Did you eventually get it working. I still can’t access Icecast outside of home assistant