Amniotic: An ambient sound mixer for Home Assistant, for Sound Masking, Sleep Sounds, etc

Hi all!

I’ve finally released my first Home Assistant project, just as I’d long threatened! It’s published on GitHub and PyPI. If you happen to fall into its tiny niche of interest, check it out!

Amniotic

A multi-output ambient sound mixer for Home Assistant.

Amniotic lets you use a single device to create on-the-fly, custom ambient audio mixes - e.g. mixing Waterfall sounds with Birdsong on one set of speakers, while playing Fireplace sounds from a second audio device - to suit your tastes and environment.

The library integrates with Home Assistant via MQTT as a new device, allowing you to create and control ambient mixes from the Home Assistant interface.

The latest update allows installing as a Home Assistant Addon!

Home Assistant Addon

To add as an Addon, click here:

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

Why Would I Want Such a Thing?

I won’t explain the general reasons for introducing non-musical sounds into one’s environment, but if you find sound masking helps you concentrate in noisy environments, if you’re (as I am) slightly misophonic, if you use white noise machines to induce sleep or relaxation, or if you just think sound is an important factor in setting a pleasant ambience, then you might find Amniotic useful.

Can’t I do This with Spotify, Volumio, HifiBerry etc.?

Since those systems are intended for music, they aren’t designed for playing or mixing multiple streams simultaneously with a single device, even if set up in multi-room configurations. Also, the streaming services often won’t allow a single account to play multiple streams, even if multiple devices are used.

These limitations motivated me to create Amniotic.

Switching between Themes with the Theme pull-down, you’ll be able to enable/disable each one, set their relative volume and their output devices etc.

Since these controls are exposed as Home Assistant entities, you can also define and play custom mixes from scenes, scripts, automations, etc. - and anything else Home Assistant will allow.

11 Likes

Now updated to run as a Docker Image:

Docker Image

There’s also a pre-built Docker Image available, so you can run on a NAS or home server etc. To run in container, use this command to map through sound devices, audio and config files:

docker run --device /dev/snd --volume <local audio path>:/root/.local/share/amniotic --volume <local config path>:/root/.config/amniotic/ fmtr/amniotic:latest
1 Like

The latest update adds sensor entities to expose more information about the media currently playing within the selected Theme.

Update with pip install amniotic --upgrade

1 Like

The latest update exposes the updater to Home Assistant, so newer versions can be installed from there. Updating will restart automatically and the device will reappear running the latest version, so all quite seamless.

Update controls:

image

Update status (sensor):

image

1 Like

The latest update quite a major one.

Themes can now be created and populated all via the Home Assistant interface (so you don’t need local files). I’ve added a YouTube link downloader, so you can build themes from YouTube ambient audio videos. Amniotic will split out the audio track and download it into your current Theme.

Is there a way to install it as a Supervisor addon? Because im running HassOS

1 Like

Hi!

This was on “the list” but wasn’t much of a priority as it’s not my personal use case. Even so, I’ve just had a look at what it would involve, and it would probably be a lot simpler than I’d imagined.

I’ll probably take a look at it fairly soon. Keep an eye on this thread!

The latest update allows installing as a Home Assistant Addon!

Home Assistant Addon

To add as an Addon, click here:

Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.

1 Like

I just installed it as an addon but sadly it doesnt detect my Media players. Theres only Standard and Dummy. All my other Devices are Google cast Devices and available als media_player entities

1 Like

Ah. So it doesn’t communicate with external media entities. The audio devices it lists in the Addon are directly connected to the HA instance. I’m assuming you don’t see any cos you don’t have any installed (or passed through).

So in my test use case, for example, the Pi running HA has a USB DAC and a USB Speaker connected, and Amniotic can output Themes to one (or more) of them.

2 Likes

This is really nice. Can’t use it though, all my devices are also media players.

3 Likes

+1. All my home speakers are driven by Google chromecast audio devices.

2 Likes

Thanks for the feedback! Since it isn’t my use case, I hadn’t targeted media_player entities. Not sure how feasible it will be. But since there seems to be more interest in that, I’ll look at what it will involve.

7 Likes

Hi all and Happy New Year :partying_face:!

Today I released a new version. Have a look!

This is a “milestone” release as Amniotic now implements all the features I had imagined when I first started the project. Some of the more notable recently added are:

  • Current state (i.e. what Themes are playing, on which devices, their volumes, etc.) can now be saved/loaded as a persistent, named Preset.
  • When Amniotic is (gracefully) restarted, the last state is remembered and resumed.
  • Current state is now also exposed as JSON data via a Sensor, so multiple Amniotics can be synchronized via HA Automations.
  • Precision volume controls (i.e. configurable Up/Down buttons) have been added, as precisely setting volume via a 0-100 slider was quite fiddly on mobile.

There are also some more minor features, plus numberless bug fixes and resource efficiency improvements. See all the changes since my last update here.

Some guidance re: installing would be nice.

The addon requires a “location” config property which is explained nowhere in the documentation. No idea what it does, what value should be supplied, etc.

The dashboard you’re showing off is nowhere to be found either.

Hi,

Sorry if it’s been a nuisance. The location field shouldn’t be required. You should be able to leave it empty. If it’s required for you, let me know more as it could be a bug in HA.

As for what it’s for, you can find that in the example config file (although admittedly that’s not obvious). Unfortunately, the HA addon schema won’t let me add a description for the variable.

As for the dashboard, that’s just one I made in Lovelave. Let me know if you want me to share it.

Indeed I just tried reisntalling Amniotic, and the location field is needed.

The base config.yaml of addons indeed does not let you define a hint, however… You can do that with translations! See e.g. the AirSonos addon:

config.yaml only lets you define named config fields, whereas providing a translation YAML will allow HA to load the name and description fields, which lets you add some annotations/hints, plus more readable names.

I think it would also be a worthwhile effort to investigate the possibility of publishing RTSP streams from the addon, which could then be added to HA as (for now) a “Generic Camera”, then dispatch it to any media player that supports said stream.

Another thing I’d consider is creating a custom component that could bind to the service, and provide a dashboard, similar to what you’ve created in Lovelace, within the integrations page, allowing the configuration of a stream.

Basically, the goal of my above rambling is to be able to create multiple “online radio” streams - the addon would spawn the streams, the custom component would allow configuring them, and HA can take over from there, matching the streams with the players.

And finally, I’d also love to see some built in support for open licensing ambient sound providers (e.g. BBC Sounds, or freesound.org).

1 Like

Thanks a lot for the advice and thoughtful suggestions.

Coincidentally, I was looking at streaming an audio output via RTSP (which PulseAudio apparently supports via a module) recently. But forwarding that stream to a media player entity hadn’t occurred to me. That could be really useful.

Nor was I aware of the ambient sound providers. Support for those would seem like a natural aim for the project.

I’ll certainly consider these options when planning next steps, now I have the initially-planned features implemented.

I’ve looked into Python audio APIs, and I think, if you plan on rewriting things, that GStreamer would be the right option - it allows multiple input streams, outputs to standard PulseAudio devices, and that PulseAudio stream can then be output as RTSP.

The refreshed Media page now contains a bunch of online radios, all of them are RTSP. Coincidentally, most smart speakers (Amazon Echo, Chromecast, even AirPlay) support direct RTSP playback, which the Media interface can take care of. So, as long as your addon/component can populate a new category there, you can output as many streams as you want!

I’ll look into how plausible it would be to switch the “backend” to GS. Btw where are you seeing those online streams? My Media folder doesn’t have them.