Skip to content

Instantly share code, notes, and snippets.

@vvv279
Forked from AlexxIT/radio.yaml
Created June 30, 2021 13:32
Show Gist options
  • Save vvv279/68db58ec0073f92d76e2061589cb46cd to your computer and use it in GitHub Desktop.
Save vvv279/68db58ec0073f92d76e2061589cb46cd to your computer and use it in GitHub Desktop.
Список радиостанций для колонок Яндекса
input_select:
radio:
name: Радио
options: ['-']
icon: mdi:radio
python_script: # https://github.com/AlexxIT/PythonScriptsPro
automation:
trigger:
platform: homeassistant
event: start
action:
service: python_script.exec
data:
source: |
import requests
import re
r = requests.get('https://yandex.ru/support/station/radio.html')
radios = re.findall(r'headers="radio__table_nfk_ylr_f3b__entry__1">(.+?)</td>', r.text)
hass.services.call('input_select', 'set_options', {
'entity_id': 'input_select.radio',
'options': sorted(set(radios))
})
script:
play_radio:
alias: Включи радио
sequence:
- service: media_player.play_media
entity_id: media_player.yandex_station_mini # поменяйте на вашу станцию
data_template:
media_content_id: Включи радио {{ states("input_select.radio") }}
media_content_type: command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment