Running HA in container. Downloaded/installed ESPHome. ESPHome option is displayed in my HA sidebar, but selecting that option displays a page with ‘ESPHome’ title, then after a few seconds page goes white (with sad face). I think this means it cannot connect. I can access ESPHome through separate port (6052), but would like to resolve the connection through HA. Any thoughts?
If I hover on the ‘white’ page, it says 192.168.2.30 took too long to respond.
Portainer shows ESPHome as ‘healthy’. However, no IP or Port is listed for ESPHome. My .yaml file (for ESPHome) does contain ports: -6052:6052/tsp. I do not see a declared IP in my .yaml. Do I need to add these.
Thanks for the response aceindy.
My original HA configuration was set up using ‘Docker’ containers and .yaml files executed using ‘docker-compose’. A single .yaml file launches Portainer (ports 9000:9000), Home Assistant (network_mode: host), and Mosquitto (ports: 1883 & 9001). I require a second .yaml file to launch zigbee2mqtt. Apparently, zigbee2mqtt expected to find Mosquitto pre-loaded, and inclusion in my primary .yaml did not provide sufficient delay.
Subsequently, I added ESPHome. ESPHome resides in a separate ‘Docker’ container, and executes using a separate .yaml file (expressing network_mode: host and ports 6052:6052).
Currently, ‘ESPHome’ is listed as an option in my Home Assistant side panel. However,when I select it, I receive the ‘192.168.2.30 took too long to respond’ error. I can access ESPHome directly by :6052. However, I would like ability to access ESPHome through my Home Assistant.
Wondering if using separate .yaml files confuses the ‘network_mode: host’ element? Or, should I simply remove ‘network_mode: host’ from my ESPHome .yaml and simply declare the port?
OK, here might lie the issue. On perusal of my Home Assistant, I do not have an integration for ESPHome. Maybe why I can’t connect. When I attempt to complete integration, I am asked for the API key. "Unable to connect to the ESPHome device. Make sure the device’s YAML configuration includes an ‘API’ section. I don’t see an API key! How do I find my ESPHome API key?
I have added ‘api.encryption.key’ to the yaml. I have stopped and restarted the ESPHome docker container. Home Assistant still cannot connect, and responds with…
“Unable to connect to the ESPHome device. Make sure the device’s YAML configuration includes an ‘API’ section”
I copied the API key from a device I was programming using ESPHome. The API key is now safely located in my ‘secrets’ file. This does not seem to have resolved my issue, and I remain confused.
I think you are mixing two things up there. That yaml is your docker compose file to start the ESPHome Device Builder container on port 6052. The Error about the API key is related to a specific device YAML section and is documented here:
It’s so HA core can communicate with the specific ESP device, and that device’s config is in /home/opt/esphome/config – that’s where the api key goes.
I also run my ESPHome Device Builder in its own container separate from the HA core container. I’m not sure you can click on a sidebar link to access the separate container (unlike when running HAOS). I’m not sure how you ended up with the sidebar link if running everything in Docker.
The API key is configured in the device’s yaml, and is asked for when the device is added to home assistant.
The device should be automatically discovered
If not, you can add the integration manually
The adding of the integration is done by adopting a device running esphome software (compiled with the API key). After connecting to the specified IP address and port (of the esphome device and NOT the esphome container), HA will ask for the API key.
Another thing that might be worth mentioning, the esphome container (or supervised app) is only required for compiling, but is not required to run for esphome devices to communicate with home assistant (mine is always stopped unless i want to add or reconfigure en existing/new device)
That was also the reason I removed it from my sidebar (as it would only mention esphome wasn’t running)
Thanks gents,
Some of this began to occur to me last evening (i.e., that the API is related to the device and not the builder). But, as I do not have background in this area, I struggle to fully grasp it. Thanks for the insight. As I am able to access ESPHome directly through my browser, I’ll accept that as the preferred pathway.