Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save willwhui/98b3595ab5a2b15cf55f260e615829f9 to your computer and use it in GitHub Desktop.

Select an option

Save willwhui/98b3595ab5a2b15cf55f260e615829f9 to your computer and use it in GitHub Desktop.
为hass添加独立的喇叭作为media_player
@willwhui
Copy link
Copy Markdown
Author

willwhui commented Jan 8, 2018

首先安装 vlc-nox,就是vlc的no x window版本:

sudo apt-get update
sudo apt-get install vlc-nox

然后连好音频线。
参照这里: https://www.raspberrypi.org/documentation/configuration/audio-config.md
将音频输出强制指向耳机:
运行:

sudo raspi-config

根据文章指引进行设置。
估计等效于此命令:

amixer cset numid=3 1

然后根据 https://home-assistant.io/components/media_player.vlc/ 进行配置
即,只需要在配置文件(configuration.yaml)中新增以下内容即可

media_player:
  - platform: vlc
    name: speaker_1
    # arguments: '--alsa-audio-device=hw:1,0' 不需要,且在我这里无法工作,因为指定的硬件配置是错误的

根据文章所述,还需要将homeassistant用户添加到audio group:

sudo usermod -a -G audio homeassistant

@willwhui
Copy link
Copy Markdown
Author

willwhui commented Jan 8, 2018

调整音量

不知为何声音太小,这里有通过hass配置声音的办法:
https://home-assistant.io/components/media_player/

    - service: media_player.volume_set
      entity_id: media_player.speaker_1
      data:
        volume_level: 1.0

然而并不能增大音量。

在树莓派命令行输入命令:

alsamixer 

然后在控制台按方向键增大减少音量。

于是可以了。
hass配置文件中的音量控制可以去掉了。

@willwhui
Copy link
Copy Markdown
Author

willwhui commented Jan 8, 2018

但是我的几个小喇叭,在没有播放音频的时候都有电流噪音,不好。
如果能像google home那样安静就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment