Advertisement
zubir2k

Home Assistant Online Radio - Now Playing (REST)

Jul 15th, 2021
1,384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.14 KB | None | 0 0
  1. #####################################
  2. ## Online Radio Now Playing - REST ##
  3. #####################################
  4. ## NOTES:
  5. ## Due to some station does not support JSON, sensor.radio_now_playing will only display station name.
  6. ## Otherwise, it will include the now playing value from the REST sensors
  7. sensor:
  8. - platform: template
  9.   sensors:
  10.     radio_now_playing:
  11.       friendly_name: "Radio Now Playing Title"
  12.       icon_template: mdi:radio
  13.       value_template: >-
  14.         {% if is_state("input_select.radio_station", "Please Select") %} No station selected
  15.         {% elif is_state("input_select.radio_station", "Mix FM") %} Mix FM - {{states.sensor.radio_mix_fm_now_playing.state}}
  16.         {% elif is_state("input_select.radio_station", "Hitz FM") %} Hitz FM - {{states.sensor.radio_hitz_fm_now_playing.state}}
  17.         {% elif is_state("input_select.radio_station", "Era FM") %} Era FM - {{states.sensor.radio_era_fm_now_playing.state}}
  18.         {% elif is_state("input_select.radio_station", "Sinar FM") %} Sinar FM - {{states.sensor.radio_sinar_fm_now_playing.state}}
  19.         {% else %} {{states.input_select.radio_station.state}}
  20.         {% endif %}
  21. - platform: rest
  22.   name: Radio Mix FM Now Playing
  23.   resource: https://scraper2.onlineradiobox.com/my.mix
  24.   value_template: '{{ value_json.title }}'
  25.   scan_interval: 15 # adjust accordingly to avoid your IP being blocked if interval is too short.
  26. - platform: rest
  27.   name: Radio Hitz FM Now Playing
  28.   resource: https://scraper2.onlineradiobox.com/my.hitzfm
  29.   value_template: '{{ value_json.title }}'
  30.   scan_interval: 15 # adjust accordingly to avoid your IP being blocked if interval is too short.
  31. - platform: rest
  32.   name: Radio Sinar FM Now Playing
  33.   resource: https://scraper2.onlineradiobox.com/my.sinar
  34.   value_template: '{{ value_json.title }}'
  35.   scan_interval: 15 # adjust accordingly to avoid your IP being blocked if interval is too short.
  36. - platform: rest
  37.   name: Radio Era FM Now Playing
  38.   resource: https://scraper2.onlineradiobox.com/my.era
  39.   value_template: '{{ value_json.title }}'
  40.   scan_interval: 15 # adjust accordingly to avoid your IP being blocked if interval is too short.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement