Objective
I have often noticed that we only have the TV on for background noise. Using 250W just for that is inefficient, so I bought a sound bar that supports Chromecast and integrates nicely into Home Assistant. Using a sound bar for this purpose has its challenges: it only needs to play when someone is present, it needs to be silent when someone actually wants to watch TV, and so on. Although most of the time it will play internet radio, playing music from other sources (especially YouTube) should be as easy as possible.
Another reason for a dedicated speaker is to play voice notifications such as daily chores, laundry finishing notifications, calendar events, weather forecasts, notifications about people in the front yard and so on. It would be great if the notifications were in Slovenian, only to differentiate from most personal assistants that don’t support my native language. Speaking of personal assistants, voice commands are not necessary, as this is just another form of remote control, which a theoretical autonomous house should not need.
Example of voice announcement (Slovenian):
Hardware
I have been looking for a speaker with the following features for a long time:
- Chromecast for integration with Home Assistant and Music Assistant (more on that later)
- satisfactory music quality (I’m not very demanding)
- a subwoofer
- as few cables as possible
- as little money as possible
So I found and purchased Polk Signa S3. First for the bioclimatic pergola, and later another one for the central living area.
Integration into Home Assistant
The sound bar is integrated to the Home Assistant using add-on called Music Assistant. It allows integration with Home Assistant, Chromecast speakers, YouTube and TuneIn, among others.
It can be installed as an Addon for Home Assistant or, if using Docker, as a separate container:
|
|
Although I hate to use network_mode: host, in this case I had to because it’s the only way to get multicast traffic (mdns udp/5353) to the application in the container due to limitation in the Linux kernel’s implementation of multicast
Automation Logic
The logic is implemented in AppDaemon, which allows you to run Python code and interact with Home Assistant.
The speaker plays the selected internet radio as long as someone is present in the living space. How to reliably detect human presence is a science in itself, which I wrote about here.
Playback does not start if:
- The TV is playing content
- the time is between 00:30 and 8:30
- the user cancels the operation from the interface
Voice notifications are managed via separate Appdaemon that collects the notifications and plays them at the appropriate moment. External apps can add their notifications to the queue for playback.
Each notification must contain:
- a message in text format
- a unique identifier
- time limits (before, after)
- optional person. The message will only be played when the person’s face is identified from the video feed.
When the conditions for the playback of the message are fullfilled, the message is converted from text to Slovenian speech, which is then played over the sound bar. For the text-to-speech conversion, I use the Home Assistant integration with Microsoft TTS, which calls the Azure’s TTS service.
Current notifications:
- Someone is in the yard
- The washing machine has finished washing
- The dryer has finished
- Events from the family calendar for the current week
- Unfinished regular and emergency tasks
- Morning greetings to the master of the house, weather forecast and key house statuses
- The car is charging