Add connections to PassiveBluetoothProcessorEntity (#102854)
parent
e0885ef109
commit
43915fbaf3
|
@ -9,6 +9,7 @@ from typing import TYPE_CHECKING, Any, Generic, TypedDict, TypeVar, cast
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import (
|
||||
ATTR_CONNECTIONS,
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_NAME,
|
||||
CONF_ENTITY_CATEGORY,
|
||||
|
@ -16,7 +17,7 @@ from homeassistant.const import (
|
|||
EntityCategory,
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH, DeviceInfo
|
||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||
from homeassistant.helpers.entity_platform import async_get_current_platform
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
|
@ -644,6 +645,8 @@ class PassiveBluetoothProcessorEntity(Entity, Generic[_PassiveBluetoothDataProce
|
|||
self._attr_unique_id = f"{address}-{key}"
|
||||
if ATTR_NAME not in self._attr_device_info:
|
||||
self._attr_device_info[ATTR_NAME] = self.processor.coordinator.name
|
||||
if device_id is None:
|
||||
self._attr_device_info[ATTR_CONNECTIONS] = {(CONNECTION_BLUETOOTH, address)}
|
||||
self._attr_name = processor.entity_names.get(entity_key)
|
||||
|
||||
@property
|
||||
|
|
|
@ -1208,6 +1208,7 @@ async def test_integration_with_entity_without_a_device(
|
|||
assert entity_one.unique_id == "aa:bb:cc:dd:ee:ff-temperature"
|
||||
assert entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"name": "Generic",
|
||||
}
|
||||
assert entity_one.entity_key == PassiveBluetoothEntityKey(
|
||||
|
@ -1396,6 +1397,7 @@ async def test_integration_multiple_entity_platforms(
|
|||
assert sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-pressure"
|
||||
assert sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1412,6 +1414,7 @@ async def test_integration_multiple_entity_platforms(
|
|||
assert binary_sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-motion"
|
||||
assert binary_sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1556,6 +1559,7 @@ async def test_integration_multiple_entity_platforms_with_reload_and_restart(
|
|||
assert sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-pressure"
|
||||
assert sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1572,6 +1576,7 @@ async def test_integration_multiple_entity_platforms_with_reload_and_restart(
|
|||
assert binary_sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-motion"
|
||||
assert binary_sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1636,6 +1641,7 @@ async def test_integration_multiple_entity_platforms_with_reload_and_restart(
|
|||
assert sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-pressure"
|
||||
assert sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1652,6 +1658,7 @@ async def test_integration_multiple_entity_platforms_with_reload_and_restart(
|
|||
assert binary_sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-motion"
|
||||
assert binary_sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1730,6 +1737,7 @@ async def test_integration_multiple_entity_platforms_with_reload_and_restart(
|
|||
assert sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-pressure"
|
||||
assert sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
@ -1746,6 +1754,7 @@ async def test_integration_multiple_entity_platforms_with_reload_and_restart(
|
|||
assert binary_sensor_entity_one.unique_id == "aa:bb:cc:dd:ee:ff-motion"
|
||||
assert binary_sensor_entity_one.device_info == {
|
||||
"identifiers": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"connections": {("bluetooth", "aa:bb:cc:dd:ee:ff")},
|
||||
"manufacturer": "Test Manufacturer",
|
||||
"model": "Test Model",
|
||||
"name": "Test Device",
|
||||
|
|
Loading…
Reference in New Issue