How to share /media in addon config.json?

I’m trying to create an Add-on that has access to the files in /media. (I have a usb hard drive mounted as /media/usb-sda1). I’m running Home Assistant OS on a raspberry pi 4.

From the docs, it looks like this can be done using “map” in config.json. See Add-On Configuration | Home Assistant Developer Docs

This doesn’t work for me. The docker container appears to have a /media folder available, but it contains subdirectories cdrom, floppy, usb.

Minimal working example to show the issue:

config.json

{
  "name": "Test share media",
  "version": "0.1",
  "slug": "testapp",
  "description": "Add-on that lists contents of /media to the log and exits",
  "startup": "once",
  "boot": "manual",
  "options": {},
  "schema": {}, 
  "arch": ["amd64", "armv7", "armhf", "i386" , "aarch64"],
  "map": ["media"],
}

Dockerfile

ARG BUILD_FROM=homeassistant/amd64-base:latest
FROM $BUILD_FROM

ENV LANG C.UTF-8

WORKDIR /
ENTRYPOINT ["ls","/media"]

LABEL io.hass.version="VERSION" io.hass.type="addon" io.hass.arch="armhf|aarch64|i386|amd64"

The log shows cdrom floppy usb

However if I ssh into homeassistant and run ls /media it returns usb-sda1 usb-sda2

Does anyone know how I can access usb-sda1 from inside my Add-on?

Thanks!

1 Like

I had a network share of my music mounted to /media and then persisted to the image via a docker volume, but 2022.2 broke it… I’m not sure if having an existing /media/ folder in there is intentional or not, but because that’s there I can’t do that anymore, and I suspect that it’s interrupting what you’re trying to do, too.