mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
ESPHome: Use MAC as unique ID (#83741)
* ESPHome: Use MAC as unique ID * Normalize incoming zeroconf/dhcp macs * Update comment * Test ESPHome without mac in zeroconf * Use format_mac * Remove unique ID index from DomainData
This commit is contained in:
30
tests/components/esphome/test_init.py
Normal file
30
tests/components/esphome/test_init.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""ESPHome set up tests."""
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from aioesphomeapi import DeviceInfo
|
||||
|
||||
from homeassistant.components.esphome import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_unique_id_updated_to_mac(hass, mock_client, mock_zeroconf):
|
||||
"""Test we update config entry unique ID to MAC address."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={CONF_HOST: "test.local", CONF_PORT: 6053, CONF_PASSWORD: ""},
|
||||
unique_id="mock-config-name",
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
mock_client.device_info = AsyncMock(
|
||||
return_value=DeviceInfo(
|
||||
mac_address="1122334455aa",
|
||||
)
|
||||
)
|
||||
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.unique_id == "11:22:33:44:55:aa"
|
||||
Reference in New Issue
Block a user