Add configuration URL to Efergy (#57839)

Co-authored-by: Franck Nijhof <git@frenck.dev>
pull/57870/head
Robert Hillis 2021-10-16 14:33:17 -04:00 committed by GitHub
parent 845652da15
commit 4b474f47f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 21 deletions

View File

@ -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"],
)

View File

@ -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