Advertisement
GrzegorzM

Play Radio from URL without delays displaying title and background image

Sep 11th, 2022 (edited)
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.54 KB | None | 0 0
  1. # script for playing radio from URL in Home Assistant without delay
  2. # optionally 'title' and 'image' can be specified to display in the specified media player(s)
  3. alias: Radio Graj
  4. fields:
  5.   entity_id:
  6.     name: Media player entitity ID(s)
  7.     required: true
  8.     example: media_player.jbl_salon
  9.     selector:
  10.       entity:
  11.         multiple: true
  12.         domain: media_player
  13.   url:
  14.     name: Radio link
  15.     description: Link of the radio
  16.     required: true
  17.     example: http://195.150.20.7/rmf_fm
  18.     selector:
  19.       text: null
  20.   title:
  21.     name: Media player title
  22.     required: false
  23.     example: Radio ZET
  24.     selector:
  25.       text: null
  26.   image:
  27.     name: Media player background image
  28.     required: false
  29.     example: /local/radio/logo_radio_zet.png
  30.     selector:
  31.       text: null
  32.   force_play:
  33.     name: Force to play immediately
  34.     description: Required if playback for the specified URL is delayed for several seconds
  35.     required: false
  36.     selector:
  37.       boolean: null
  38. sequence:
  39.   - service: media_player.play_media
  40.     data:
  41.       media_content_id: "{{url}}"
  42.       media_content_type: music
  43.       extra:
  44.         metadata:
  45.           metadataType: 1
  46.           title: "{{title}}"
  47.           images:
  48.             - url: "{{image}}"
  49.     target:
  50.       entity_id: "{{entity_id}}"
  51.   - if:
  52.       - condition: template
  53.         value_template: "{{force_play is defined and force_play == true}}"
  54.     then:
  55.       - service: media_player.media_play
  56.         target:
  57.           entity_id: "{{entity_id}}"
  58. mode: single
  59. icon: mdi:radio
  60.  
  61. #####################################################################################
  62. #usage in the Mini Media Player card
  63.     shortcuts:
  64.       buttons:
  65.         - id: script.radio_graj
  66.           name: RMF FM
  67.           type: script
  68.           data:
  69.             title: RMF FM
  70.             url: http://195.150.20.7/rmf_fm
  71.             image: /local/radio/logo_rmf_fm.png
  72.             force_play: true
  73.         - id: script.radio_graj
  74.           name: Radio ZET
  75.           type: script
  76.           data:
  77.             title: Radio ZET
  78.             url: http://zet-net-01.cdn.eurozet.pl:8400/
  79.             image: /local/radio/logo_radio_zet.png
  80. #####################################################################################
  81. #usage as the service (image location /config/www/radio)
  82. service: script.radio_graj
  83. data:
  84.   entity_id:
  85.    - media_player.jbl_sypialnia
  86.     - media_player.jbl_salon
  87.   url: http://195.150.20.7/rmf_fm
  88.   title: RMF FM
  89.   image: /local/radio/logo_rmf_fm.png
  90.   force_play: true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement