From 21f2c664d9db9a80440443bf1314d920cecd6db0 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 16 Feb 2022 05:13:16 -0600 Subject: [PATCH] Enable dhcp flows for elkm1 registered devices (#66583) --- homeassistant/components/elkm1/__init__.py | 9 ++++++++- homeassistant/components/elkm1/manifest.json | 5 ++++- homeassistant/generated/dhcp.py | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/elkm1/__init__.py b/homeassistant/components/elkm1/__init__.py index 8ab9c0ac73f..8b0dd26fc32 100644 --- a/homeassistant/components/elkm1/__init__.py +++ b/homeassistant/components/elkm1/__init__.py @@ -14,6 +14,7 @@ import voluptuous as vol from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( + ATTR_CONNECTIONS, CONF_EXCLUDE, CONF_HOST, CONF_INCLUDE, @@ -28,6 +29,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType @@ -286,6 +288,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DOMAIN][entry.entry_id] = { "elk": elk, "prefix": conf[CONF_PREFIX], + "mac": entry.unique_id, "auto_configure": conf[CONF_AUTO_CONFIGURE], "config": config, "keypads": {}, @@ -420,6 +423,7 @@ class ElkEntity(Entity): """Initialize the base of all Elk devices.""" self._elk = elk self._element = element + self._mac = elk_data["mac"] self._prefix = elk_data["prefix"] self._name_prefix = f"{self._prefix} " if self._prefix else "" self._temperature_unit = elk_data["config"]["temperature_unit"] @@ -499,10 +503,13 @@ class ElkAttachedEntity(ElkEntity): device_name = "ElkM1" if self._prefix: device_name += f" {self._prefix}" - return DeviceInfo( + device_info = DeviceInfo( identifiers={(DOMAIN, f"{self._prefix}_system")}, manufacturer="ELK Products, Inc.", model="M1", name=device_name, sw_version=self._elk.panel.elkm1_version, ) + if self._mac: + device_info[ATTR_CONNECTIONS] = {(CONNECTION_NETWORK_MAC, self._mac)} + return device_info diff --git a/homeassistant/components/elkm1/manifest.json b/homeassistant/components/elkm1/manifest.json index a72a0221907..909bfa3bd02 100644 --- a/homeassistant/components/elkm1/manifest.json +++ b/homeassistant/components/elkm1/manifest.json @@ -3,7 +3,10 @@ "name": "Elk-M1 Control", "documentation": "https://www.home-assistant.io/integrations/elkm1", "requirements": ["elkm1-lib==1.2.0"], - "dhcp": [{"macaddress":"00409D*"}], + "dhcp": [ + {"registered_devices": true}, + {"macaddress":"00409D*"} + ], "codeowners": ["@gwww", "@bdraco"], "dependencies": ["network"], "config_flow": true, diff --git a/homeassistant/generated/dhcp.py b/homeassistant/generated/dhcp.py index b0edb218b7b..25b82220223 100644 --- a/homeassistant/generated/dhcp.py +++ b/homeassistant/generated/dhcp.py @@ -23,6 +23,7 @@ DHCP: list[dict[str, str | bool]] = [ {'domain': 'broadlink', 'macaddress': '24DFA7*'}, {'domain': 'broadlink', 'macaddress': 'A043B0*'}, {'domain': 'broadlink', 'macaddress': 'B4430D*'}, + {'domain': 'elkm1', 'registered_devices': True}, {'domain': 'elkm1', 'macaddress': '00409D*'}, {'domain': 'emonitor', 'hostname': 'emonitor*', 'macaddress': '0090C2*'}, {'domain': 'emonitor', 'registered_devices': True},