mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use MAC address in Twinkly DeviceInfo.connections
(#133708)
This commit is contained in:
parent
7326555f03
commit
aad1d6a25d
@ -28,7 +28,7 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
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 homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -97,6 +97,7 @@ class TwinklyLight(LightEntity):
|
|||||||
# They are expected to be updated using the device_info.
|
# They are expected to be updated using the device_info.
|
||||||
self._name = conf.data[CONF_NAME] or "Twinkly light"
|
self._name = conf.data[CONF_NAME] or "Twinkly light"
|
||||||
self._model = conf.data[CONF_MODEL]
|
self._model = conf.data[CONF_MODEL]
|
||||||
|
self._mac = device_info["mac"]
|
||||||
|
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
@ -114,6 +115,7 @@ class TwinklyLight(LightEntity):
|
|||||||
"""Get device specific attributes."""
|
"""Get device specific attributes."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self._attr_unique_id)},
|
identifiers={(DOMAIN, self._attr_unique_id)},
|
||||||
|
connections={(CONNECTION_NETWORK_MAC, self._mac)},
|
||||||
manufacturer="LEDWORKS",
|
manufacturer="LEDWORKS",
|
||||||
model=self._model,
|
model=self._model,
|
||||||
name=self._name,
|
name=self._name,
|
||||||
|
@ -7,6 +7,7 @@ from homeassistant.components.twinkly.const import DEV_NAME
|
|||||||
TEST_HOST = "test.twinkly.com"
|
TEST_HOST = "test.twinkly.com"
|
||||||
TEST_ID = "twinkly_test_device_id"
|
TEST_ID = "twinkly_test_device_id"
|
||||||
TEST_UID = "4c8fccf5-e08a-4173-92d5-49bf479252a2"
|
TEST_UID = "4c8fccf5-e08a-4173-92d5-49bf479252a2"
|
||||||
|
TEST_MAC = "aa:bb:cc:dd:ee:ff"
|
||||||
TEST_NAME = "twinkly_test_device_name"
|
TEST_NAME = "twinkly_test_device_name"
|
||||||
TEST_NAME_ORIGINAL = "twinkly_test_original_device_name" # the original (deprecated) name stored in the conf
|
TEST_NAME_ORIGINAL = "twinkly_test_original_device_name" # the original (deprecated) name stored in the conf
|
||||||
TEST_MODEL = "twinkly_test_device_model"
|
TEST_MODEL = "twinkly_test_device_model"
|
||||||
@ -31,6 +32,7 @@ class ClientMock:
|
|||||||
self.device_info = {
|
self.device_info = {
|
||||||
"uuid": self.id,
|
"uuid": self.id,
|
||||||
"device_name": TEST_NAME,
|
"device_name": TEST_NAME,
|
||||||
|
"mac": TEST_MAC,
|
||||||
"product_code": TEST_MODEL,
|
"product_code": TEST_MODEL,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
}),
|
}),
|
||||||
'device_info': dict({
|
'device_info': dict({
|
||||||
'device_name': 'twinkly_test_device_name',
|
'device_name': 'twinkly_test_device_name',
|
||||||
|
'mac': '**REDACTED**',
|
||||||
'product_code': 'twinkly_test_device_model',
|
'product_code': 'twinkly_test_device_model',
|
||||||
'uuid': '4c8fccf5-e08a-4173-92d5-49bf479252a2',
|
'uuid': '4c8fccf5-e08a-4173-92d5-49bf479252a2',
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user