Home Assistant and ESPhome in Docker

I stumbled upon this reading this thread on ESPHome.
This is great :smiley: I ha ve been looking for a solution for ages ! I have two USB dongles on my NUC, one Zigbee and one Z-Wave. Each time the NUC restarts (luckily, not often), they get swapped.
Will try this solution tonite !

Just sharing the solution I found somewhere on the internet after I got fed up with similar switches of USB devices. It works for me, if it also does for you you can like the post :grinning:

Sharing is building knowlegde

Hi,
The instructions at the top of this thread have been great. I have migrated from an rpi4 setup to a small home server. Thanks very much for your help in setting up home assistant.

But I am having a little trouble with esp home. I have the docker running OK, but I do not know where to put the configuration information from my old rpi4.

There was an esphome directory within homeassistant config directory. I have tried to put its contents in the config directory in the esphome docker but it does not work.

Can you please let me know where to copy the config information?

Thanks

I use a other directory:

    volumes:
      - /home/shares/pi/esphome/config:/config

copy to this

Thanks!

It is working fine now.

Have you set up a media directory on the docker home assistant?

There is a discussion here about the media location https://community.home-assistant.io/t/media-folder-location/231755/12

I have set this up and can select one of my own sounds in a media player, but it does not play.

I think this error appears:

homeassistant.components.sonos.exception.SonosUpdateError: Error calling SonosMediaPlayerEntity._play_media on media_player.decking: HTTPConnectionPool(host=‘192.168.86.33’, port=1400): Read timed out. (read timeout=9.5)

Is this an issue with docker port forwarding that I need to address?

Since you linked my post I’ll chime in.

I think your issue here is in regards to the later part of my post, specifically the authSig. Anything above the www directory requires authentication. Sonos isn’t authenticating to HA and has no way to do so. The only option would be to place a folder in the www folder with the sound files. The problem with that approach is that they would then be accessible without any authentication to anyone in the world.

In my post I’m specifically addressing HA sending files to the Mobile client. That client is authenticated to HA and can therefore access the local directory.

Thanks for your suggestions.

I have relocated my sound file to beneath the www directory, as you suggested, but can still not play the sounds to the sonos devices.

Initially I could see the error message I mentioned on the screen when I was running 2024.9.1. I manually updated to 2024.9.2 and still cannot play the sounds but can no longer cause the error message to appear on the screen.

My small server is actually running Open Media Vault and I am using its docker compose add-on to run my Home Assistant and ESPhome dockers. I am wondering if that may be the cause of this unexpected behaviour.

It looks like the new docker Home Assistant has retained some settings from my rpi4 Hass Home Assistant installation.

I have been following up with error log files and can see that the issue is related to authSIG.

val="ERROR_CANT_REACH_SERVER"/><TransportErrorDescription val="2,0,Relaxing River Sounds - Peaceful Forest River - 3 Hours Long.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI,192.168.86.30:8123,http://192.168.86.30:8123/media/local/Relaxing%20River%20Sounds%20-%20Peaceful%20Forest%20River%20-%203%20Hours%20Long.mp3?

The address 192.168.86.30:8123 is not the address of the current docker Home Assistant. It was the address of the rpi4 install, but my server is at 192.168.86.34.

I have attempted to rectify this issue by using the Local IP integration, which reports the correct ip. I have restarted HA several times but the problem persists.

Well it has been a lot of looking around, but there is a file called core.config in the .storage directory that contains a lot of configuration information, in particular a field called

“internal_url”: “http://192.168.86.34:8123”,

I manually edited this line to contain the correct ip address, then restarted Home Assistant and I am now able to play media files to the sonos device.

Hooray!

I recall in the previous installation on the rpi4 that it was possible to specify the internal url and have not found the location in the docker HA system.

Hopefully this helps someone else.

2 days later…
I cannot believe that I have suddenly lost the ability to play media files on the sonos device.

The favorites tab in the media browser has suddenly reported that there are no items.

I have not been able to find any discussions of this issue. Am I really alone?

It turns out I did not read the manual properly enough ie https://www.home-assistant.io/integrations/media_source/#local-media

My configuration.yaml file now has this at top and seems to work fine:

media_source:

homeassistant:
#
   media_dirs:
     local: /config/media

the next day…

The history has stopped working for all the entities. The useful time-trend does not appear.
The reading I have done has not helped with my install, https://community.home-assistant.io/t/psa-2024-7-recorder-problems/746428

when I run recorder.purge I get this:

Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:299
integration: Recorder (documentation, issues)
First occurred: 12:08:35 PM (1 occurrences)
Last logged: 12:08:35 PM

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

some time later my configuration.yaml now contains:

# Example configuration.yaml entry from https://www.home-assistant.io/integrations/recorder/#disk-space-requirements
recorder:
  purge_keep_days: 5
  auto_purge: false

  include:
    domains:
      - sensor
      - switch
      - media_player
  
# Basic configuration.yaml entry from https://www.home-assistant.io/integrations/history/
history:  
  

It took several restarts of HA and even closing the docker before the database seemed to come back to life.

I am only including this blow-by-blow description in case it helps someone else migrating from a raspberry pi installation (mine was running smoothly for about 4 years)

What I have learnt lately is that docker Home Assistant seems to “listen” much more intently to the configuration.yaml file than I was used to. Stuff seemed to work in HassOS on the rpi and I am feeling pretty dumb that the transition was so difficult, but still this has been a good opportunity to fix up some things. For example, I used to use Zigbee2MQTT and ZHA on the rpi and have now consolidated my zigbee network on ZHA.