Advertisement
dale3h

[Home Assistant] Media Player Online Radio

Aug 2nd, 2016
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.47 KB | None | 0 0
  1. automation:
  2.   - alias: Stop Streaming Radio
  3.     trigger:
  4.       platform: state
  5.       entity_id: input_select.radio_station
  6.       to: 'None'
  7.     condition: or
  8.     conditions:
  9.       - condition: state
  10.         entity_id: input_select.radio_player
  11.         state: 'Office'
  12.       - condition: state
  13.         entity_id: input_select.radio_player
  14.         state: 'Bedroom'
  15.       - condition: state
  16.         entity_id: input_select.radio_player
  17.         state: 'Kitchen'
  18.     action:
  19.       service: media_player.turn_off
  20.       data_template:
  21.         entity_id: >
  22.          {%- if is_state('input_select.radio_player', 'Office') -%}
  23.             media_player.office
  24.           {%- elif is_state('input_select.radio_player', 'Bedroom') -%}
  25.             media_player.bedroom
  26.           {%- elif is_state('input_select.radio_player', 'Kitchen') -%}
  27.             media_player.kitchen
  28.           {%- endif -%}
  29.  
  30.   - alias: Start Streaming Radio
  31.     trigger:
  32.       - platform: state
  33.         entity_id: input_select.radio_station
  34.         to: 'X96'
  35.       - platform: state
  36.         entity_id: input_select.radio_station
  37.         to: 'KISS FM'
  38.       - platform: state
  39.         entity_id: input_select.radio_station
  40.         to: 'Country Time'
  41.     condition: or
  42.     conditions:
  43.       - condition: state
  44.         entity_id: input_select.radio_player
  45.         state: 'Office'
  46.       - condition: state
  47.         entity_id: input_select.radio_player
  48.         state: 'Bedroom'
  49.       - condition: state
  50.         entity_id: input_select.radio_player
  51.         state: 'Kitchen'
  52.     action:
  53.       service: media_player.play_media
  54.       data_template:
  55.         entity_id: >
  56.          {%- if is_state('input_select.radio_player', 'Office') -%}
  57.             media_player.office
  58.           {%- elif is_state('input_select.radio_player', 'Bedroom') -%}
  59.             media_player.bedroom
  60.           {%- elif is_state('input_select.radio_player', 'Kitchen') -%}
  61.             media_player.kitchen
  62.           {%- endif -%}
  63.         media_content_id: >
  64.          {%- if is_state('input_select.radio_station', 'X96') -%}
  65.             'http://ice41.securenetsystems.net/KXRK?type=.mp4'
  66.           {%- elif is_state('input_select.radio_station', 'KISS FM') -%}
  67.             'http://ice41.securenetsystems.net/KISS?type=.mp4'
  68.           {%- elif is_state('input_select.radio_station', 'Country Time') -%}
  69.             'http://ice41.securenetsystems.net/CTRY?type=.mp4'
  70.           {%- endif -%}
  71.         media_content_type: 'audio/mp4'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement