安装个人修改版的musicbox和tmux
sudo apt-get install tmux
sudo apt-get install mpg123
git clone https://github.com/cloudswave/musicbox.git
cd musicbox
python setup.py install
可以手动在终端测试播放器是否正常:musicbox -c “?”,这个命令会随机开始播放音乐。
tmux的作用是模拟终端session在后台播放音乐。
配置shell_command 、触发器和动作
configuration.yaml
shell_command:
musicbox_play: su - pi -c ‘tmux new-session -d -s musicbox musicbox -c “?”’ # 需要使用pi用户执行,否则播放不出声音
musicbox_kill: su - pi -c ‘tmux kill-session -t musicbox’
group : !include groups.yaml
automation: !include automations.yaml
script : !include scripts.yaml
logger:
default: info
logs:
homeassistant.components.shell_command: info