Streaming audio from Plasma to a Chromecast

Chromecast devices in the sound settings

This morning, while browsing the web, I wanted to listen to a Podcast from my laptop, and thought “Hey, can I stream this to our stereo?”. As it turns out, that’s rather easy to achieve, so I thought I’d share it here.
The media devices in our home are connected using Chromecasts, which are small dongles that allow playing media on them, meaning you can play for example a video from your phone on the projector in the living room: very convenient.

I didn’t know if that was easily achievable with audio from my Plasma/Linux laptop and a quick search turned up “pulseaudio-dlna” which adds Chromecast devices on the local networks as output devices.

On my KDE Neon laptop, it’s as easy as installing pulseaudio-dlna from the standard repositories and then starting “pulseaudio-dlna” from the commandline. Then, I can pick an output device from the panel popup and the audio stream changed to my stereo.

$ sudo apt install pulseaudio-dlna
$ sudo pulseaudio-dlna
Added the device "Stereo (Chromecast)".


My Lavalamp

For our living room, I wanted to create a new lamp which isn’t as static as most other lamps, something dynamic but nothing too intrusive.
I was also interested in individually addressable led strips for quite some time, so I started prototyping in last year’s late summer. In december, I finished this project, and called it lavalamp after the classic decorative lamp with rising blobs of fluid which was invented in the 60s.

Lavalamp Show

The lamp uses LEDs for its lighting, there are 576 individually addressable LEDs used, which shine in four directions. The lamp can produce dynamic patterns and effects. There’s a web interface I can use to change its effect, but it also reacts to its surroundings, steered by Home Assistant, my home automation platform of choice. This means that the lamp is automatically switched off when we go to bed, leave the house or want to watch a movie. It can also be voice-controlled.


The ESP8266 microchip running the LEDs

The lamp’s electronic components are an ESP8266 microchip and WS2812b addressable leds. (This means I can change the color and brightness of every single LED individually.) I’ve written custom firmware for the microcontroller (you can find it on my github page), it basically runs a small webserver on its Wifi interface, offering configuration data in JSON format to a mobile-friendly JavaScript application which can run in a browser on your phone. The LEDs are driven by the FastLED library, which is a fantastic piece of software offering fast mathematical functions and low-level data protocols to manipulate the LEDs in my lamp.
With this setup, I achieve 50 frames per second for most of the effects that I’m using in the lamp, so the animations all look smoothly and feel quite natural. I think that’s really impressive, given the rather low specs of the microchip and its price point at around 2€.

The case of the lamp has a wooden foot, sitting around a concrete block which holds the lamp firmly in place and provides some isolation in case anything goes wrong in the electronic parts. The light from the LEDs is diffused through frosted glass, giving it a nice glow.

Building the lamp was a fun project. I didn’t give myself a deadline, but rather took all the time I needed spread out over a period of four months to get all the individual parts in place. I had to learn quite some new tricks, which made this project really interesting. From cutting and building the wooden case to soldering and programming the microchip. In the end, I’m really happy how the lamp turned out. It brings live into our place, while usually not being too distracting.
For further improvements, I built a USB port into the foot of the lamp, so I can just plug in my laptop and add new effects or tweak existing ones.
I’m not quite done with it yet, I want to improve the existing effects on the lamp further, but I’ll also probably build a separate unit that analyses the music playing in our living room to make the lavalamp music-reactive.