mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Provide a human readable error when an esphome ble proxy connection fails (#81266)
This commit is contained in:
parent
1106df158d
commit
11d7e1e45f
@ -7,6 +7,7 @@ import logging
|
|||||||
from typing import Any, TypeVar, cast
|
from typing import Any, TypeVar, cast
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from aioesphomeapi import ESP_CONNECTION_ERROR_DESCRIPTION, BLEConnectionError
|
||||||
from aioesphomeapi.connection import APIConnectionError, TimeoutAPIError
|
from aioesphomeapi.connection import APIConnectionError, TimeoutAPIError
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from bleak.backends.characteristic import BleakGATTCharacteristic
|
from bleak.backends.characteristic import BleakGATTCharacteristic
|
||||||
@ -182,8 +183,17 @@ class ESPHomeClient(BaseBleakClient):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if error:
|
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(
|
connected_future.set_exception(
|
||||||
BleakError(f"Error while connecting: {error}")
|
BleakError(
|
||||||
|
f"Error {ble_connection_error_name} while connecting: {human_error}"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "ESPHome",
|
"name": "ESPHome",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
"documentation": "https://www.home-assistant.io/integrations/esphome",
|
||||||
"requirements": ["aioesphomeapi==11.2.0"],
|
"requirements": ["aioesphomeapi==11.3.0"],
|
||||||
"zeroconf": ["_esphomelib._tcp.local."],
|
"zeroconf": ["_esphomelib._tcp.local."],
|
||||||
"dhcp": [{ "registered_devices": true }],
|
"dhcp": [{ "registered_devices": true }],
|
||||||
"codeowners": ["@OttoWinter", "@jesserockz"],
|
"codeowners": ["@OttoWinter", "@jesserockz"],
|
||||||
|
@ -153,7 +153,7 @@ aioecowitt==2022.09.3
|
|||||||
aioemonitor==1.0.5
|
aioemonitor==1.0.5
|
||||||
|
|
||||||
# homeassistant.components.esphome
|
# homeassistant.components.esphome
|
||||||
aioesphomeapi==11.2.0
|
aioesphomeapi==11.3.0
|
||||||
|
|
||||||
# homeassistant.components.flo
|
# homeassistant.components.flo
|
||||||
aioflo==2021.11.0
|
aioflo==2021.11.0
|
||||||
|
@ -140,7 +140,7 @@ aioecowitt==2022.09.3
|
|||||||
aioemonitor==1.0.5
|
aioemonitor==1.0.5
|
||||||
|
|
||||||
# homeassistant.components.esphome
|
# homeassistant.components.esphome
|
||||||
aioesphomeapi==11.2.0
|
aioesphomeapi==11.3.0
|
||||||
|
|
||||||
# homeassistant.components.flo
|
# homeassistant.components.flo
|
||||||
aioflo==2021.11.0
|
aioflo==2021.11.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user