ESPhome module fails integration install

I configured and flashed an ESP32 in the ESPHome HA add-on. It is auto-discovery in my HA Integrations, but when I attempt to configure it, it fails. The logs are below. The logging isn’t that helpful, in that I have no idea what JSON file is failing to decode. I assume this is related to the ESP configuration, but I’m not sure.

Any suggestions are appreciated!

HAOS 2023.3.5
ESPHome 2023.3.0

Logger: aiohttp.server
Source: helpers/aiohttp_client.py:67 
First occurred: 5:07:30 PM (2 occurrences) 
Last logged: 5:07:40 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 67, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/esphome/config_flow.py", line 177, in async_step_discovery_confirm
    return await self._async_try_fetch_device_info()
  File "/usr/src/homeassistant/homeassistant/components/esphome/config_flow.py", line 149, in _async_try_fetch_device_info
    and await self._retrieve_encryption_key_from_dashboard()
  File "/usr/src/homeassistant/homeassistant/components/esphome/config_flow.py", line 384, in _retrieve_encryption_key_from_dashboard
    noise_psk = await dashboard.api.get_encryption_key(device["configuration"])
  File "/usr/local/lib/python3.10/site-packages/esphome_dashboard_api/__init__.py", line 103, in get_encryption_key
    config = await self.get_config(configuration)
  File "/usr/local/lib/python3.10/site-packages/esphome_dashboard_api/__init__.py", line 93, in get_config
    return await self.request(
  File "/usr/local/lib/python3.10/site-packages/esphome_dashboard_api/__init__.py", line 54, in request
    return await resp.json()
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 67, in json
    return await super().json(*args, loads=loads, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1120, in json
    return loads(stripped.decode(encoding))
orjson.JSONDecodeError: unexpected character: line 1 column 3282 (char 3281)

Perhaps you could bless us with your yaml and the log from esphome.

1 Like

I ultimately determined the problem was in my ESPHome yaml.

I was using the auto-generated api entry, which included the encryption key. I ended up providing my port and credentials there, and it worked. Need to circle back and determine why the key wasn’t working, but it’s interesting to know this was a configuration problem.