node-sonos-http-api is a simple tool for controlling Sonos devices with an API like function, that makes controlling Sonos via Home Assistant (or similar platform) super easy.
I am running node-sonos-http-api on a dedicated LXC instance, with 256M RAM and 1 vCPU. I am using Home Assistant's Command Line Switche Component to toggle various actions such as playing specific playlists at a specific volume, turn off all Sonos at bedtime, etc.
For this guide, both SELinux and firewalld is assumed to be disabled.
Let's Get Started!
1.) updates and pre-requisites:
yum -y install git && yum -y update wget https://rpm.nodesource.com/setup_4.x -O /tmp/node_repo.sh # Download script to add node repo bash /tmp/node_repo.sh # Add node repo yum -y install nodejs # Install nodejs npm install npm -g
2.) install node-sonos-http-api:
cd /opt git clone https://github.com/jishi/node-sonos-http-api.git # Download node-sonos-http-api cd node-sonos-http-api && npm install --production # install node-sonos-http-api dependencies
3.) systemd file:
vi /etc/systemd/system/sonosapi.service --- [Unit] Description=Sonos HTTP API Daemon After=syslog.target network.target [Service] Type=simple ExecStart=/usr/bin/node /opt/node-sonos-http-api/server.js Restart=always RestartSec=10 [Install] WantedBy=multi-user.target ---
rm -rf /tmp/node_repo.sh systemctl enable sonosapi.service reboot
And that's it! It's a fairly easy install, and after the reboot, the service will be running on port 5005. There is no web interface, so I hope that's not what you were expecting. I'd recommend you take a look at the README file for this project to understand it's use.