mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 23:41:48 -05:00
Add reason for unvailability to opendisplay (#172909)
This commit is contained in:
@@ -15,7 +15,11 @@ from opendisplay import (
|
||||
OpenDisplayError,
|
||||
)
|
||||
|
||||
from homeassistant.components.bluetooth import async_ble_device_from_address
|
||||
from homeassistant.components.bluetooth import (
|
||||
BluetoothReachabilityIntent,
|
||||
async_address_reachability_diagnostics,
|
||||
async_ble_device_from_address,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -83,9 +87,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenDisplayConfigEntry)
|
||||
ble_device = async_ble_device_from_address(hass, address, connectable=True)
|
||||
if ble_device is None:
|
||||
raise ConfigEntryNotReady(
|
||||
f"Could not find OpenDisplay device with address {address}"
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="device_not_found",
|
||||
translation_placeholders={
|
||||
"address": address,
|
||||
"reason": async_address_reachability_diagnostics(
|
||||
hass,
|
||||
address.upper(),
|
||||
BluetoothReachabilityIntent.CONNECTION,
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
encryption_key = _get_encryption_key(entry)
|
||||
|
||||
try:
|
||||
|
||||
@@ -22,7 +22,11 @@ from opendisplay import (
|
||||
from PIL import Image as PILImage, ImageOps
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.bluetooth import async_ble_device_from_address
|
||||
from homeassistant.components.bluetooth import (
|
||||
BluetoothReachabilityIntent,
|
||||
async_address_reachability_diagnostics,
|
||||
async_ble_device_from_address,
|
||||
)
|
||||
from homeassistant.components.http.auth import async_sign_path
|
||||
from homeassistant.components.media_source import async_resolve_media
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
@@ -108,7 +112,7 @@ def _get_entry_for_device(call: ServiceCall) -> OpenDisplayConfigEntry:
|
||||
if entry is None or entry.state is not ConfigEntryState.LOADED:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="device_not_found",
|
||||
translation_key="config_entry_not_found",
|
||||
translation_placeholders={"address": mac_address},
|
||||
)
|
||||
|
||||
@@ -171,7 +175,14 @@ async def _async_upload_image(call: ServiceCall) -> None:
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="device_not_found",
|
||||
translation_placeholders={"address": address},
|
||||
translation_placeholders={
|
||||
"address": address,
|
||||
"reason": async_address_reachability_diagnostics(
|
||||
call.hass,
|
||||
address.upper(),
|
||||
BluetoothReachabilityIntent.CONNECTION,
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
current = asyncio.current_task()
|
||||
|
||||
@@ -74,8 +74,11 @@
|
||||
"authentication_error": {
|
||||
"message": "Authentication failed. Please update the encryption key."
|
||||
},
|
||||
"config_entry_not_found": {
|
||||
"message": "Config entry not found: `{address}`"
|
||||
},
|
||||
"device_not_found": {
|
||||
"message": "Could not find Bluetooth device with address `{address}`."
|
||||
"message": "Could not find Bluetooth device with address `{address}`. Reason: {reason}"
|
||||
},
|
||||
"invalid_device_id": {
|
||||
"message": "Device `{device_id}` is not a valid OpenDisplay device."
|
||||
|
||||
Reference in New Issue
Block a user