|
首先在树莓派中安装VLC-NOX,链接putty:
sudo apt-get install vlc-nox
sudo usermod -a -G audio homeassistant
speaker-test
如果能在树莓派的耳机插口中听到“沙沙”的声音,说明VLC工作正常了!
在Configuration.yaml中加入
media_player :
- platform: vlc
name: VLC player
homeassistant中出现如下组件
###############Configuration.yaml中配置网络广播###################
将以下代码添加到Configuration.yaml中
#选择频道
input_select:
radio_station:
name: '广播频道:'
options:
- 100% NL
- Veronica
- Classic FM
- Sleep Radio
- Radio Art - Sleep
- Ambi Nature Radio
- Calm Radio - Sleep
- Dinamo.FM Sleep
- 89.9 The Wave
#选择播放器
home_radio:
name: '播放音源:'
options:
- "VLC 播放器"
- "主卧播放器"
- "客厅播放器"
initial: "VLC 播放器"
icon: mdi:speaker-wireless
#音量划杆
input_slider:
volume_radio:
name: '音量调节'
icon: mdi:volume-high
min: 0
max: 1
step: 0.05
#播放脚本
script:
radio_house:
alias: '开始播放'
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.home_radio", "VLC 播放器") %} media_player.vlc_player
{% elif is_state("input_select.home_radio", "主卧播放器") %} media_player.bedroom_kodi
{% elif is_state("input_select.home_radio", "客厅播放器") %} media_player.livingroom_kodi
{% endif %}
volume_level: '{{ states.input_slider.volume_radio.state }}'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.home_radio", "VLC 播放器") %} media_player.vlc_player
{% elif is_state("input_select.home_radio", "主卧播放器") %} media_player.bedroom_kodi
{% elif is_state("input_select.home_radio", "客厅播放器") %} media_player.livingroom_kodi
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "100% NL") %}
{% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state("input_select.radio_station", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
{% elif is_state("input_select.radio_station", "Radio Art - Sleep") %}
{% elif is_state("input_select.radio_station", "Ambi Nature Radio") %} http://94.23.252.14:8067/stream
{% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
{% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
{% elif is_state("input_select.radio_station", "89.9 The Wave") %} http://chns.streamon.fm/
{% endif %}
media_content_type: 'music'
automation:
- alias: 'Set Radio Volume'
trigger:
- platform: state
entity_id: input_slider.volume_radio
action:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.home_radio", "VLC 播放器") %} media_player.vlc_player
{% elif is_state("input_select.home_radio", "主卧播放器") %} media_player.bedroom_kodi
{% elif is_state("input_select.home_radio", "客厅播放器") %} media_player.livingroom_kodi
{% endif %}
volume_level: '{{ states.input_slider.volume_radio.state }}'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.home_radio", "VLC 播放器") %} media_player.vlc_player
{% elif is_state("input_select.home_radio", "主卧播放器") %} media_player.bedroom_kodi
{% elif is_state("input_select.home_radio", "客厅播放器") %} media_player.livingroom_kodi
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "100% NL") %}
{% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state("input_select.radio_station", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
{% elif is_state("input_select.radio_station", "Radio Art - Sleep") %}
{% elif is_state("input_select.radio_station", "Ambi Nature Radio") %} http://94.23.252.14:8067/stream
{% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
{% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
{% elif is_state("input_select.radio_station", "89.9 The Wave") %} http://chns.streamon.fm/
{% endif %}
media_content_type: 'music'
#播放面板分组
group:
play_media_radio:
view: no
name: '播放面板'
icon: mdi:view-dashboard
entities:
- input_select.radio_station
- input_select.home_radio
- input_slider.volume_radio
- script.radio_house
安装正常后homeassistant中会出现如下组件:
|
评分
-
查看全部评分
|