Compare commits

...

4 Commits

Author SHA1 Message Date
J. Nick Koston deff0e15cc Merge branch 'dev' into switchbot-reachability-diagnostics 2026-05-30 08:50:34 -05:00
J. Nick Koston ddf5613ac3 Explain why a Switchbot device could not be found 2026-05-29 11:11:27 -05:00
J. Nick Koston ec0bd39b7c Add async_address_reachability_diagnostics to bluetooth API 2026-05-29 10:53:33 -05:00
J. Nick Koston c6844a8223 Bump habluetooth to 6.8.0 2026-05-29 10:46:38 -05:00
2 changed files with 18 additions and 2 deletions
+17 -1
View File
@@ -6,6 +6,7 @@ from typing import Any
import switchbot
from homeassistant.components import bluetooth
from homeassistant.components.bluetooth import BluetoothReachabilityIntent
from homeassistant.components.sensor import ConfigType
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
@@ -310,6 +311,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: SwitchbotConfigEntry) ->
translation_placeholders={
"sensor_type": entry.data[CONF_SENSOR_TYPE],
"address": entry.data[CONF_ADDRESS],
"reason": bluetooth.async_address_reachability_diagnostics(
hass,
entry.data[CONF_ADDRESS].upper(),
BluetoothReachabilityIntent.CONNECTION,
),
},
)
@@ -331,7 +337,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: SwitchbotConfigEntry) ->
raise ConfigEntryNotReady(
translation_domain=DOMAIN,
translation_key="device_not_found_error",
translation_placeholders={"sensor_type": sensor_type, "address": address},
translation_placeholders={
"sensor_type": sensor_type,
"address": address,
"reason": bluetooth.async_address_reachability_diagnostics(
hass,
address.upper(),
BluetoothReachabilityIntent.CONNECTION
if connectable
else BluetoothReachabilityIntent.PASSIVE_ADVERTISEMENT,
),
},
)
cls = CLASS_BY_DEVICE.get(sensor_type, switchbot.SwitchbotDevice)
@@ -384,7 +384,7 @@
"message": "The device ID {device_id} does not belong to SwitchBot integration."
},
"device_not_found_error": {
"message": "Could not find Switchbot {sensor_type} with address {address}"
"message": "Could not find Switchbot {sensor_type} with address {address}: {reason}"
},
"device_without_config_entry": {
"message": "The device ID {device_id} is not associated with a config entry."