Giter Club home page Giter Club logo

somaspeaker's Introduction

somaspeaker

A web and MQTT remote control service for Raspberry Pi

Please see Issues 136 and 140 for full tutorials: https://magpi.raspberrypi.com/

What it does

This service allows you to access SomaFm streaming via Raspberry Pi. It is intended to act as a starting point for the Sonos Play:1 upcycling project in the above MagPi issues.

Installation

Update and install dependancies:

sudo apt update && sudo apt upgrade
sudo apt install git python3-pip
pip3 install flask paho-mqtt

Clone this repo to the target Raspberry Pi:

cd
git clone https://github.com/mrpjevans/somaspeaker.git

Configuration

Decide whether you wnat the simple web interface or MQTT control. If you do not know what MQTT control is, you want web, which is the defauly.

For MQTT edit the config file:

nano ~/somaspeaker/config.py

Change mode = "web" to mode = "mqtt" and set the host, port, topic and client id as show in the example.

Usage

To run as a web server:

cd ~/somaspeaker
flask --app somaspeaker run -h 0.0.0.0 -p 3000

You should now be able to access the service on http://ip-address:3000 where ip-address is the IP address or hostname of your Raspberry Pi.

To run as a MQTT client:

cd ~/somaspeaker
python3 somaspeaker.py

Running on boot

Web

sudo nano /usr/lib/systemd/somaspeaker.service

Add the following:

[Service]
WorkingDirectory=/home/pj/somaspeaker
ExecStart=/usr/local/bin/flask -app somaspeaker run -h 0.0.0.0 -p 3000
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable the service:

sudo systemctl enable /usr/lib/systemd/somaspeaker.service
sudo systemctl start somaspeaker.service

MQTT

sudo nano /usr/lib/systemd/somaspeaker.service

Add the following:

[Service]
WorkingDirectory=/home/pj/somaspeaker
ExecStart=/usr/bin/python3 somaspeaker.py
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable the service:

sudo systemctl enable /usr/lib/systemd/somaspeaker.service
sudo systemctl start somaspeaker.service

MQTT Messages

In MQTT mode the service will respond to the following messages:

Select a channel and start streaming:

channel:name

Where name is the name of the SomaFM channel (Run ~/somaspeaker/somafm.sh channels to get a valid list)

Stop streaming:

stop

Resume streaming the current channel:

play

Increase volume:

volume:up

Decrease volume:

volume:down

Acknowlegements

Streaming of the SomaFM service is thanks to https://github.com/rockymadden/somafm-cli

somaspeaker's People

Contributors

mrpjevans avatar pjmindera avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.