Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christophberger/auxin-switcher-for-3sixty
Switch a 3sixty radio to AUX-IN when a Raspi starts playing music.
https://github.com/christophberger/auxin-switcher-for-3sixty
Last synced: about 15 hours ago
JSON representation
Switch a 3sixty radio to AUX-IN when a Raspi starts playing music.
- Host: GitHub
- URL: https://github.com/christophberger/auxin-switcher-for-3sixty
- Owner: christophberger
- License: bsd-3-clause
- Created: 2021-12-28T20:08:09.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-19T13:01:21.000Z (7 months ago)
- Last Synced: 2024-04-20T13:46:41.212Z (7 months ago)
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AUX-IN Switcher for the Teufel 3sixty Radio
## Problem
- A 3sixty radio from Teufel - **no, this part is not the problem!**
- The radio has lot of cool features but no AirPlay
- And the Spotify client has a few issues (or maybe it's only my local net, but anyway...)## Solution
- A Raspberry Pi with shairport-sync and raspotify connected to the auxiliary input
## Now I have a new Problem!
- I want to **auto-switch** the 3sixty to the aux input when the Raspi starts playing. Because I am lazy, and standing up, walking 2 steps over to the radio and hitting the Source button a few times is not an option.
## New Solution
Luckily,
- The 3sixty has a Frontier Silicon chipset.
- Frontier Silicon built a REST-like HTTP API into the chipset. (It's only REST-**like** and no standard REST but who cares.)So -
- I wrote a Go program that detects music output on a Raspi.
- If music starts playing, the program then
- wakes up the 3sixty if needed,
- saves the currently active source,
- and switches the radio to aux-in.
- If music stops playing, the program
- checks if the radio was switched to a different source in the meantime
- if so, the program leaves the radio alone
- else it switches back to the previous source
- and puts the radio into standby mode.The Go code started out from code generated by Postman.
The Postman queries I built were based on [this inofficial FSAPI doc](https://github.com/flammy/fsapi/blob/master/FSAPI.md).
Detecting if the Raspi plays music is easy once you [find out how]((https://howchoo.com/linux/how-to-detect-that-audio-is-currently-being-output-in-linux-and-use-it-to-call-a-program#create-an-audio-output-monitor-script)) - `cat /proc/asound/card1/pcm0p/sub0/status` is the command line version.
Go code compiles to a single binary with no dependencies. And Go can cross-compile to a different architecture without the need for installing the target system's compiler toolchain locally. These attributes of Go make it super easy to `scp` the program to the Raspi and run it as a `systemd` service. No complicated build/deploy routines needed (but setting up the `systemd` files is still a manual step; templates included in the repo).
## Disclaimer
I built this project for my own purposes (obviously) but I am happy to share it here in case anybody else has a 3sixty (or some other Frontier Silicon based radio) and wonders how to auto-switch to aux-in in case a Raspi plays music.
## Instructions
If you really want to build this app for your own use (no guarantees that it will work outside my particular setup), follow these steps.
1. Ensure you have [Go](https://go.dev) installed.
2. Clone the repo.
3. If you do this already on the target Raspi: run `go build` and move the binary to `/usr/local/bin/` (sudo required)
4. Else run `GOOS=linux GOARCH=arm go build && scp 3sixty [email protected]:/home/pi/` (given your Raspi user is `pi`)
Then `ssh` into your Raspi and move the binary to `/usr/local/bin` (sudo required)
5. Edit 3sixty.conf and 3sixty.service as needed. (Required: base URL to your radio & access PIN)
6. Move 3sixty.conf to /etc/ and 3sixty.service to /etc/systemd/system
7. Run `sudo systemctl daemon-reload`
8. Run `sudo systemctl start 3sixty && sudo systemctl status 3sixty`
9. To auto-start the service after system boot, run `sudo systemctl enable 3sixty`
10. Check the status - it should be "active (running)"
11. If the service fails, check `/var/log/syslog`