Skip to content

Commit

Permalink
Improve esphome bluetooth error reporting (home-assistant#81326)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 1, 2022
1 parent 0bca9a6 commit d87ca0b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions homeassistant/components/esphome/bluetooth/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
from typing import Any, TypeVar, cast
import uuid

from aioesphomeapi import ESP_CONNECTION_ERROR_DESCRIPTION, BLEConnectionError
from aioesphomeapi import (
ESP_CONNECTION_ERROR_DESCRIPTION,
ESPHOME_GATT_ERRORS,
BLEConnectionError,
)
from aioesphomeapi.connection import APIConnectionError, TimeoutAPIError
import async_timeout
from bleak.backends.characteristic import BleakGATTCharacteristic
Expand Down Expand Up @@ -207,7 +211,9 @@ def _on_bluetooth_connection_state(
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}"
human_error = ESPHOME_GATT_ERRORS.get(
error, f"Unknown error code {error}"
)
connected_future.set_exception(
BleakError(
f"Error {ble_connection_error_name} while connecting: {human_error}"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/esphome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ESPHome",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/esphome",
"requirements": ["aioesphomeapi==11.4.1"],
"requirements": ["aioesphomeapi==11.4.2"],
"zeroconf": ["_esphomelib._tcp.local."],
"dhcp": [{ "registered_devices": true }],
"codeowners": ["@OttoWinter", "@jesserockz"],
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ aioecowitt==2022.09.3
aioemonitor==1.0.5

# homeassistant.components.esphome
aioesphomeapi==11.4.1
aioesphomeapi==11.4.2

# homeassistant.components.flo
aioflo==2021.11.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ aioecowitt==2022.09.3
aioemonitor==1.0.5

# homeassistant.components.esphome
aioesphomeapi==11.4.1
aioesphomeapi==11.4.2

# homeassistant.components.flo
aioflo==2021.11.0
Expand Down

0 comments on commit d87ca0b

Please sign in to comment.