Give users a hint that their bluetooth adapter has been ignored (#87727)
This commit is contained in:
parent
cbaf4764e7
commit
4cebc767b5
3 changed files with 26 additions and 2 deletions
|
@ -108,7 +108,13 @@ class BluetoothConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
if details[ADAPTER_ADDRESS] not in configured_addresses
|
if details[ADAPTER_ADDRESS] not in configured_addresses
|
||||||
]
|
]
|
||||||
if not unconfigured_adapters:
|
if not unconfigured_adapters:
|
||||||
return self.async_abort(reason="no_adapters")
|
ignored_adapters = len(
|
||||||
|
self._async_current_entries(include_ignore=True)
|
||||||
|
) - len(self._async_current_entries(include_ignore=False))
|
||||||
|
return self.async_abort(
|
||||||
|
reason="no_adapters",
|
||||||
|
description_placeholders={"ignored_adapters": str(ignored_adapters)},
|
||||||
|
)
|
||||||
if len(unconfigured_adapters) == 1:
|
if len(unconfigured_adapters) == 1:
|
||||||
self._adapter = list(self._adapters)[0]
|
self._adapter = list(self._adapters)[0]
|
||||||
self._details = self._adapters[self._adapter]
|
self._details = self._adapters[self._adapter]
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
|
||||||
"no_adapters": "No unconfigured Bluetooth adapters found"
|
"no_adapters": "No unconfigured Bluetooth adapters found. There are {ignored_adapters} ignored adapters."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
|
|
@ -394,3 +394,21 @@ async def test_options_flow_enabled_linux(
|
||||||
response = await ws_client.receive_json()
|
response = await ws_client.receive_json()
|
||||||
assert response["result"][0]["supports_options"] is True
|
assert response["result"][0]["supports_options"] is True
|
||||||
await hass.config_entries.async_unload(entry.entry_id)
|
await hass.config_entries.async_unload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_async_step_user_linux_adapter_is_ignored(hass, one_adapter):
|
||||||
|
"""Test we give a hint that the adapter is ignored."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
unique_id="00:00:00:00:00:01",
|
||||||
|
source=config_entries.SOURCE_IGNORE,
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN,
|
||||||
|
context={"source": config_entries.SOURCE_USER},
|
||||||
|
data={},
|
||||||
|
)
|
||||||
|
assert result["type"] == FlowResultType.ABORT
|
||||||
|
assert result["reason"] == "no_adapters"
|
||||||
|
assert result["description_placeholders"] == {"ignored_adapters": "1"}
|
||||||
|
|
Loading…
Add table
Reference in a new issue