No "/usr/src" directory

Hello!

This might be an obvious one, but I am still new to HA and cannot figure out myself. I try to install an addon to control my Sony BluRay player (this one: GitHub - alexmohr/media_player.sony: Custom component for Home Assistant to control Sony devices)

When I check the configuration in developer tools, I get

Platform error ‘media_player’ from integration ‘sony’ - cannot import name ‘save_json’ from ‘homeassistant.util.json’ (/usr/src/homeassistant/homeassistant/util/json.py)

So I went to look for /usr/src/homeassistant/homeassistant/util/json.py, but as it turns out there is not even a /usr/src directory.

I can find a json.py in /usr/lib/python3.12/site-packages/pip/_vendor/rich/. But that’s obviously not where the addon is looking for.

I assume it is related to my supervised installation.

Here’s my setup:

  • HW: Home Assistant Green
  • Core: 2025.3.4
  • Supervisor: 2025.03.3
  • Operating System: 15.0
  • Frontend: 20250306.0

Any idea what I could do? Can I fill “/usr/src” somehow?

From that repo:

To get started put /custom_components/sony/media_player.py here: <config_directory>/custom_components/sony/media_player.py When using home assistant supervised put the contents of this repo into /usr/share/hassio/homeassistant/

You are not running supervised, but HAOS, so put the component in <config_directory>/custom_components/sony/media_player.py

<config_directory> is where your configuration.yaml is located.

Thanks for your reply.

That’s what I did initially, but the integration “sony” was not found. Then I moved to “/home/hass io/custom_components” and it also did not work. Then I realized that access was only for root, so I chowned to “hass io”. After that the integration “sony” was found, but the error of my initial post occured.

I just testwise moved again to <config_directory>/custom_components/sony, but the problem with the missing json.py remains.

Inside the repo there are only 3 files:

__ init__.py
manifest.json
media_player.py

PS: “hass io” is always changed to “home assistant OS” here, so I write it with an extra space …

I digged a bit deeper. The component tries to import a JSON load and a save function.

from homeassistant.util.json import load_json, save_json

Since it worked for “load_json” but not for “save_json” I looked at the source core at: core/homeassistant/util/json.py at c8f839068cb8114ca29c9cdd74b1a42de71cdcdd · home-assistant/core · GitHub

And – surprise! – there is no save_json function inside. So maybe this was removed sometime after the custome component was released. I removed the import statement for “save_json” and then the configuration seems to be fine. At least I don’t get another error message.

The custom component does use “save_json”, so I might need to provide a function here later, but for now I am good.

Next step for me is to confirm the component does what it should. But this is not part of my initial question, which can be closed. Problem was not that “/usr/src” was empty, but that “save_json” is not a part of homeassistant.util.json (anymore).