Advertisement
dale3h

[Home Assistant] Streaming Radio Automation

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