Add manufacturer and model to bluetooth adapter device (#82769)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
873b903cf0
commit
d6e287f47a
10 changed files with 79 additions and 13 deletions
|
@ -10,10 +10,12 @@ from awesomeversion import AwesomeVersion
|
||||||
from bluetooth_adapters import (
|
from bluetooth_adapters import (
|
||||||
ADAPTER_ADDRESS,
|
ADAPTER_ADDRESS,
|
||||||
ADAPTER_HW_VERSION,
|
ADAPTER_HW_VERSION,
|
||||||
|
ADAPTER_MANUFACTURER,
|
||||||
ADAPTER_SW_VERSION,
|
ADAPTER_SW_VERSION,
|
||||||
DEFAULT_ADDRESS,
|
DEFAULT_ADDRESS,
|
||||||
AdapterDetails,
|
AdapterDetails,
|
||||||
adapter_human_name,
|
adapter_human_name,
|
||||||
|
adapter_model,
|
||||||
adapter_unique_name,
|
adapter_unique_name,
|
||||||
get_adapters,
|
get_adapters,
|
||||||
)
|
)
|
||||||
|
@ -276,6 +278,8 @@ async def async_update_device(
|
||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
name=adapter_human_name(adapter, details[ADAPTER_ADDRESS]),
|
name=adapter_human_name(adapter, details[ADAPTER_ADDRESS]),
|
||||||
connections={(dr.CONNECTION_BLUETOOTH, details[ADAPTER_ADDRESS])},
|
connections={(dr.CONNECTION_BLUETOOTH, details[ADAPTER_ADDRESS])},
|
||||||
|
manufacturer=details[ADAPTER_MANUFACTURER],
|
||||||
|
model=adapter_model(details),
|
||||||
sw_version=details.get(ADAPTER_SW_VERSION),
|
sw_version=details.get(ADAPTER_SW_VERSION),
|
||||||
hw_version=details.get(ADAPTER_HW_VERSION),
|
hw_version=details.get(ADAPTER_HW_VERSION),
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"bleak==0.19.2",
|
"bleak==0.19.2",
|
||||||
"bleak-retry-connector==2.8.5",
|
"bleak-retry-connector==2.8.5",
|
||||||
"bluetooth-adapters==0.8.0",
|
"bluetooth-adapters==0.11.0",
|
||||||
"bluetooth-auto-recovery==0.5.2",
|
"bluetooth-auto-recovery==0.5.2",
|
||||||
"bluetooth-data-tools==0.3.0",
|
"bluetooth-data-tools==0.3.0",
|
||||||
"dbus-fast==1.75.0"
|
"dbus-fast==1.75.0"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"netmap==0.7.0.2",
|
"netmap==0.7.0.2",
|
||||||
"getmac==0.8.2",
|
"getmac==0.8.2",
|
||||||
"mac-vendor-lookup==0.1.11"
|
"mac-vendor-lookup==0.1.12"
|
||||||
],
|
],
|
||||||
"codeowners": [],
|
"codeowners": [],
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
|
|
|
@ -12,7 +12,7 @@ awesomeversion==22.9.0
|
||||||
bcrypt==3.1.7
|
bcrypt==3.1.7
|
||||||
bleak-retry-connector==2.8.5
|
bleak-retry-connector==2.8.5
|
||||||
bleak==0.19.2
|
bleak==0.19.2
|
||||||
bluetooth-adapters==0.8.0
|
bluetooth-adapters==0.11.0
|
||||||
bluetooth-auto-recovery==0.5.2
|
bluetooth-auto-recovery==0.5.2
|
||||||
bluetooth-data-tools==0.3.0
|
bluetooth-data-tools==0.3.0
|
||||||
certifi>=2021.5.30
|
certifi>=2021.5.30
|
||||||
|
|
|
@ -447,7 +447,7 @@ bluemaestro-ble==0.2.0
|
||||||
# bluepy==1.3.0
|
# bluepy==1.3.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
bluetooth-adapters==0.8.0
|
bluetooth-adapters==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
bluetooth-auto-recovery==0.5.2
|
bluetooth-auto-recovery==0.5.2
|
||||||
|
@ -1055,7 +1055,7 @@ lw12==0.9.2
|
||||||
lxml==4.9.1
|
lxml==4.9.1
|
||||||
|
|
||||||
# homeassistant.components.nmap_tracker
|
# homeassistant.components.nmap_tracker
|
||||||
mac-vendor-lookup==0.1.11
|
mac-vendor-lookup==0.1.12
|
||||||
|
|
||||||
# homeassistant.components.magicseaweed
|
# homeassistant.components.magicseaweed
|
||||||
magicseaweed==1.0.3
|
magicseaweed==1.0.3
|
||||||
|
|
|
@ -361,7 +361,7 @@ blinkpy==0.19.2
|
||||||
bluemaestro-ble==0.2.0
|
bluemaestro-ble==0.2.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
bluetooth-adapters==0.8.0
|
bluetooth-adapters==0.11.0
|
||||||
|
|
||||||
# homeassistant.components.bluetooth
|
# homeassistant.components.bluetooth
|
||||||
bluetooth-auto-recovery==0.5.2
|
bluetooth-auto-recovery==0.5.2
|
||||||
|
@ -769,7 +769,7 @@ luftdaten==0.7.4
|
||||||
lxml==4.9.1
|
lxml==4.9.1
|
||||||
|
|
||||||
# homeassistant.components.nmap_tracker
|
# homeassistant.components.nmap_tracker
|
||||||
mac-vendor-lookup==0.1.11
|
mac-vendor-lookup==0.1.12
|
||||||
|
|
||||||
# homeassistant.components.maxcube
|
# homeassistant.components.maxcube
|
||||||
maxcube-api==0.4.3
|
maxcube-api==0.4.3
|
||||||
|
|
|
@ -106,6 +106,10 @@ def one_adapter_fixture():
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": True,
|
"passive_scan": True,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
):
|
):
|
||||||
|
@ -132,12 +136,20 @@ def two_adapters_fixture():
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
"hci1": {
|
"hci1": {
|
||||||
"address": "00:00:00:00:00:02",
|
"address": "00:00:00:00:00:02",
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": True,
|
"passive_scan": True,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
):
|
):
|
||||||
|
@ -164,6 +176,10 @@ def one_adapter_old_bluez():
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
):
|
):
|
||||||
|
|
|
@ -130,7 +130,10 @@ async def test_async_step_integration_discovery(hass):
|
||||||
"""Test setting up from integration discovery."""
|
"""Test setting up from integration discovery."""
|
||||||
|
|
||||||
details = AdapterDetails(
|
details = AdapterDetails(
|
||||||
address="00:00:00:00:00:01", sw_version="1.23.5", hw_version="1.2.3"
|
address="00:00:00:00:00:01",
|
||||||
|
sw_version="1.23.5",
|
||||||
|
hw_version="1.2.3",
|
||||||
|
manufacturer="ACME",
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -159,7 +162,10 @@ async def test_async_step_integration_discovery_during_onboarding_one_adapter(
|
||||||
):
|
):
|
||||||
"""Test setting up from integration discovery during onboarding."""
|
"""Test setting up from integration discovery during onboarding."""
|
||||||
details = AdapterDetails(
|
details = AdapterDetails(
|
||||||
address="00:00:00:00:00:01", sw_version="1.23.5", hw_version="1.2.3"
|
address="00:00:00:00:00:01",
|
||||||
|
sw_version="1.23.5",
|
||||||
|
hw_version="1.2.3",
|
||||||
|
manufacturer="ACME",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -187,10 +193,16 @@ async def test_async_step_integration_discovery_during_onboarding_two_adapters(
|
||||||
):
|
):
|
||||||
"""Test setting up from integration discovery during onboarding."""
|
"""Test setting up from integration discovery during onboarding."""
|
||||||
details1 = AdapterDetails(
|
details1 = AdapterDetails(
|
||||||
address="00:00:00:00:00:01", sw_version="1.23.5", hw_version="1.2.3"
|
address="00:00:00:00:00:01",
|
||||||
|
sw_version="1.23.5",
|
||||||
|
hw_version="1.2.3",
|
||||||
|
manufacturer="ACME",
|
||||||
)
|
)
|
||||||
details2 = AdapterDetails(
|
details2 = AdapterDetails(
|
||||||
address="00:00:00:00:00:02", sw_version="1.23.5", hw_version="1.2.3"
|
address="00:00:00:00:00:02",
|
||||||
|
sw_version="1.23.5",
|
||||||
|
hw_version="1.2.3",
|
||||||
|
manufacturer="ACME",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -226,7 +238,10 @@ async def test_async_step_integration_discovery_during_onboarding_two_adapters(
|
||||||
async def test_async_step_integration_discovery_during_onboarding(hass, macos_adapter):
|
async def test_async_step_integration_discovery_during_onboarding(hass, macos_adapter):
|
||||||
"""Test setting up from integration discovery during onboarding."""
|
"""Test setting up from integration discovery during onboarding."""
|
||||||
details = AdapterDetails(
|
details = AdapterDetails(
|
||||||
address=DEFAULT_ADDRESS, sw_version="1.23.5", hw_version="1.2.3"
|
address=DEFAULT_ADDRESS,
|
||||||
|
sw_version="1.23.5",
|
||||||
|
hw_version="1.2.3",
|
||||||
|
manufacturer="ACME",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -252,7 +267,10 @@ async def test_async_step_integration_discovery_during_onboarding(hass, macos_ad
|
||||||
async def test_async_step_integration_discovery_already_exists(hass):
|
async def test_async_step_integration_discovery_already_exists(hass):
|
||||||
"""Test setting up from integration discovery when an entry already exists."""
|
"""Test setting up from integration discovery when an entry already exists."""
|
||||||
details = AdapterDetails(
|
details = AdapterDetails(
|
||||||
address="00:00:00:00:00:01", sw_version="1.23.5", hw_version="1.2.3"
|
address="00:00:00:00:00:01",
|
||||||
|
sw_version="1.23.5",
|
||||||
|
hw_version="1.2.3",
|
||||||
|
manufacturer="ACME",
|
||||||
)
|
)
|
||||||
|
|
||||||
entry = MockConfigEntry(domain=DOMAIN, unique_id="00:00:00:00:00:01")
|
entry = MockConfigEntry(domain=DOMAIN, unique_id="00:00:00:00:00:01")
|
||||||
|
|
|
@ -76,12 +76,20 @@ async def test_diagnostics(
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
"hci1": {
|
"hci1": {
|
||||||
"address": "00:00:00:00:00:02",
|
"address": "00:00:00:00:00:02",
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": True,
|
"passive_scan": True,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"dbus": {
|
"dbus": {
|
||||||
|
@ -107,12 +115,20 @@ async def test_diagnostics(
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
"hci1": {
|
"hci1": {
|
||||||
"address": "00:00:00:00:00:02",
|
"address": "00:00:00:00:00:02",
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": True,
|
"passive_scan": True,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"advertisement_tracker": {
|
"advertisement_tracker": {
|
||||||
|
@ -249,6 +265,10 @@ async def test_diagnostics_macos(
|
||||||
"address": "00:00:00:00:00:00",
|
"address": "00:00:00:00:00:00",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": ANY,
|
"sw_version": ANY,
|
||||||
|
"manufacturer": "Apple",
|
||||||
|
"product": "Unknown MacOS Model",
|
||||||
|
"product_id": "Unknown",
|
||||||
|
"vendor_id": "Unknown",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"manager": {
|
"manager": {
|
||||||
|
@ -257,6 +277,10 @@ async def test_diagnostics_macos(
|
||||||
"address": "00:00:00:00:00:00",
|
"address": "00:00:00:00:00:00",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": ANY,
|
"sw_version": ANY,
|
||||||
|
"manufacturer": "Apple",
|
||||||
|
"product": "Unknown MacOS Model",
|
||||||
|
"product_id": "Unknown",
|
||||||
|
"vendor_id": "Unknown",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"advertisement_tracker": {
|
"advertisement_tracker": {
|
||||||
|
|
|
@ -1050,6 +1050,10 @@ def mock_bluetooth_adapters():
|
||||||
"hw_version": "usb:v1D6Bp0246d053F",
|
"hw_version": "usb:v1D6Bp0246d053F",
|
||||||
"passive_scan": False,
|
"passive_scan": False,
|
||||||
"sw_version": "homeassistant",
|
"sw_version": "homeassistant",
|
||||||
|
"manufacturer": "ACME",
|
||||||
|
"product": "Bluetooth Adapter 5.0",
|
||||||
|
"product_id": "aa01",
|
||||||
|
"vendor_id": "cc01",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
):
|
):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue