From 4b474f47f2ab162730a1d108711b2202ac0b94e0 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Sat, 16 Oct 2021 14:33:17 -0400 Subject: [PATCH] Add configuration URL to Efergy (#57839) Co-authored-by: Franck Nijhof --- homeassistant/components/efergy/__init__.py | 31 +++++++-------------- tests/components/efergy/test_init.py | 1 + 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/efergy/__init__.py b/homeassistant/components/efergy/__init__.py index 74bcf6ff7b0..dd6c6001259 100644 --- a/homeassistant/components/efergy/__init__.py +++ b/homeassistant/components/efergy/__init__.py @@ -5,15 +5,7 @@ from pyefergy import Efergy, exceptions from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ATTR_ATTRIBUTION, - ATTR_IDENTIFIERS, - ATTR_MANUFACTURER, - ATTR_MODEL, - ATTR_NAME, - ATTR_SW_VERSION, - CONF_API_KEY, -) +from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import device_registry as dr @@ -69,15 +61,12 @@ class EfergyEntity(Entity): self.api = api self._server_unique_id = server_unique_id self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION} - - @property - def device_info(self) -> DeviceInfo: - """Return the device information of the entity.""" - return { - "connections": {(dr.CONNECTION_NETWORK_MAC, self.api.info["mac"])}, - ATTR_IDENTIFIERS: {(DOMAIN, self._server_unique_id)}, - ATTR_MANUFACTURER: DEFAULT_NAME, - ATTR_NAME: DEFAULT_NAME, - ATTR_MODEL: self.api.info["type"], - ATTR_SW_VERSION: self.api.info["version"], - } + self._attr_device_info = DeviceInfo( + configuration_url="https://engage.efergy.com/user/login", + connections={(dr.CONNECTION_NETWORK_MAC, self.api.info["mac"])}, + identifiers={(DOMAIN, self._server_unique_id)}, + manufacturer=DEFAULT_NAME, + name=DEFAULT_NAME, + model=self.api.info["type"], + sw_version=self.api.info["version"], + ) diff --git a/tests/components/efergy/test_init.py b/tests/components/efergy/test_init.py index f32551a4e9b..07c80e7bb04 100644 --- a/tests/components/efergy/test_init.py +++ b/tests/components/efergy/test_init.py @@ -53,6 +53,7 @@ async def test_device_info(hass: HomeAssistant, aioclient_mock: AiohttpClientMoc device = device_registry.async_get_device({(DOMAIN, entry.entry_id)}) + assert device.configuration_url == "https://engage.efergy.com/user/login" assert device.connections == {("mac", "ff:ff:ff:ff:ff:ff")} assert device.identifiers == {(DOMAIN, entry.entry_id)} assert device.manufacturer == DEFAULT_NAME