Provide a human readable error when an esphome ble proxy connection fails (#81266)

pull/81265/head^2
J. Nick Koston 2022-10-30 17:43:09 -05:00 committed by GitHub
parent 1106df158d
commit 11d7e1e45f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import logging
from typing import Any, TypeVar, cast
import uuid
from aioesphomeapi import ESP_CONNECTION_ERROR_DESCRIPTION, BLEConnectionError
from aioesphomeapi.connection import APIConnectionError, TimeoutAPIError
import async_timeout
from bleak.backends.characteristic import BleakGATTCharacteristic
@ -182,8 +183,17 @@ class ESPHomeClient(BaseBleakClient):
return
if error:
try:
ble_connection_error = BLEConnectionError(error)
ble_connection_error_name = ble_connection_error.name
human_error = ESP_CONNECTION_ERROR_DESCRIPTION[ble_connection_error]
except (KeyError, ValueError):
ble_connection_error_name = str(error)
human_error = f"Unknown error code {error}"
connected_future.set_exception(
BleakError(f"Error while connecting: {error}")
BleakError(
f"Error {ble_connection_error_name} while connecting: {human_error}"
)
)
return

View File

@ -3,7 +3,7 @@
"name": "ESPHome",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/esphome",
"requirements": ["aioesphomeapi==11.2.0"],
"requirements": ["aioesphomeapi==11.3.0"],
"zeroconf": ["_esphomelib._tcp.local."],
"dhcp": [{ "registered_devices": true }],
"codeowners": ["@OttoWinter", "@jesserockz"],

View File

@ -153,7 +153,7 @@ aioecowitt==2022.09.3
aioemonitor==1.0.5
# homeassistant.components.esphome
aioesphomeapi==11.2.0
aioesphomeapi==11.3.0
# homeassistant.components.flo
aioflo==2021.11.0

View File

@ -140,7 +140,7 @@ aioecowitt==2022.09.3
aioemonitor==1.0.5
# homeassistant.components.esphome
aioesphomeapi==11.2.0
aioesphomeapi==11.3.0
# homeassistant.components.flo
aioflo==2021.11.0