Use MAC address in Twinkly `DeviceInfo.connections` (#133708)

pull/133712/head
Maciej Bieniek 2024-12-21 11:19:11 +00:00 committed by GitHub
parent 7326555f03
commit aad1d6a25d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 1 deletions

View File

@ -28,7 +28,7 @@ from homeassistant.const import (
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import (
@ -97,6 +97,7 @@ class TwinklyLight(LightEntity):
# They are expected to be updated using the device_info.
self._name = conf.data[CONF_NAME] or "Twinkly light"
self._model = conf.data[CONF_MODEL]
self._mac = device_info["mac"]
self._client = client
@ -114,6 +115,7 @@ class TwinklyLight(LightEntity):
"""Get device specific attributes."""
return DeviceInfo(
identifiers={(DOMAIN, self._attr_unique_id)},
connections={(CONNECTION_NETWORK_MAC, self._mac)},
manufacturer="LEDWORKS",
model=self._model,
name=self._name,

View File

@ -7,6 +7,7 @@ from homeassistant.components.twinkly.const import DEV_NAME
TEST_HOST = "test.twinkly.com"
TEST_ID = "twinkly_test_device_id"
TEST_UID = "4c8fccf5-e08a-4173-92d5-49bf479252a2"
TEST_MAC = "aa:bb:cc:dd:ee:ff"
TEST_NAME = "twinkly_test_device_name"
TEST_NAME_ORIGINAL = "twinkly_test_original_device_name" # the original (deprecated) name stored in the conf
TEST_MODEL = "twinkly_test_device_model"
@ -31,6 +32,7 @@ class ClientMock:
self.device_info = {
"uuid": self.id,
"device_name": TEST_NAME,
"mac": TEST_MAC,
"product_code": TEST_MODEL,
}

View File

@ -15,6 +15,7 @@
}),
'device_info': dict({
'device_name': 'twinkly_test_device_name',
'mac': '**REDACTED**',
'product_code': 'twinkly_test_device_model',
'uuid': '4c8fccf5-e08a-4173-92d5-49bf479252a2',
}),