Use DeviceEntryType in non-typechecked code too (#58646)

This commit is contained in:
Ville Skyttä 2021-11-23 11:04:33 +02:00 committed by GitHub
parent ca20fc857f
commit 39691faccc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 50 additions and 31 deletions

View file

@ -27,6 +27,7 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -358,7 +359,7 @@ class ClimaCellEntity(CoordinatorEntity):
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return device registry information.""" """Return device registry information."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self._config_entry.data[CONF_API_KEY])}, identifiers={(DOMAIN, self._config_entry.data[CONF_API_KEY])},
manufacturer="ClimaCell", manufacturer="ClimaCell",
name="ClimaCell", name="ClimaCell",

View file

@ -7,6 +7,7 @@ from homeassistant.components.sensor import (
SensorEntity, SensorEntity,
) )
from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from .const import ( from .const import (
@ -112,7 +113,7 @@ class AccountSensor(SensorEntity):
self._attr_state_class = STATE_CLASS_TOTAL self._attr_state_class = STATE_CLASS_TOTAL
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
configuration_url="https://www.coinbase.com/settings/api", configuration_url="https://www.coinbase.com/settings/api",
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self._coinbase_data.user_id)}, identifiers={(DOMAIN, self._coinbase_data.user_id)},
manufacturer="Coinbase.com", manufacturer="Coinbase.com",
name=f"Coinbase {self._coinbase_data.user_id[-4:]}", name=f"Coinbase {self._coinbase_data.user_id[-4:]}",
@ -185,7 +186,7 @@ class ExchangeRateSensor(SensorEntity):
self._attr_state_class = STATE_CLASS_MEASUREMENT self._attr_state_class = STATE_CLASS_MEASUREMENT
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
configuration_url="https://www.coinbase.com/settings/api", configuration_url="https://www.coinbase.com/settings/api",
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self._coinbase_data.user_id)}, identifiers={(DOMAIN, self._coinbase_data.user_id)},
manufacturer="Coinbase.com", manufacturer="Coinbase.com",
name=f"Coinbase {self._coinbase_data.user_id[-4:]}", name=f"Coinbase {self._coinbase_data.user_id[-4:]}",

View file

@ -156,7 +156,7 @@ class DeconzGateway:
device_registry.async_get_or_create( device_registry.async_get_or_create(
config_entry_id=self.config_entry.entry_id, config_entry_id=self.config_entry.entry_id,
configuration_url=configuration_url, configuration_url=configuration_url,
entry_type="service", entry_type=dr.DeviceEntryType.SERVICE,
identifiers={(DECONZ_DOMAIN, self.api.config.bridge_id)}, identifiers={(DECONZ_DOMAIN, self.api.config.bridge_id)},
manufacturer="Dresden Elektronik", manufacturer="Dresden Elektronik",
model=self.api.config.model_id, model=self.api.config.model_id,

View file

@ -8,6 +8,7 @@ import async_timeout
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, LENGTH_METERS from homeassistant.const import ATTR_ATTRIBUTION, LENGTH_METERS
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -123,7 +124,7 @@ class Measurement(CoordinatorEntity, SensorEntity):
def device_info(self): def device_info(self):
"""Return the device info.""" """Return the device info."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, "measure-id", self.station_id)}, identifiers={(DOMAIN, "measure-id", self.station_id)},
manufacturer="https://environment.data.gov.uk/", manufacturer="https://environment.data.gov.uk/",
model=self.parameter_name, model=self.parameter_name,

View file

@ -19,7 +19,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_MANUFACTURER, ATTR_MANUFACTURER,
ATTR_NAME, ATTR_NAME,
ATTR_SERVICE,
EVENT_CORE_CONFIG_UPDATE, EVENT_CORE_CONFIG_UPDATE,
SERVICE_HOMEASSISTANT_RESTART, SERVICE_HOMEASSISTANT_RESTART,
SERVICE_HOMEASSISTANT_STOP, SERVICE_HOMEASSISTANT_STOP,
@ -27,7 +26,11 @@ from homeassistant.const import (
from homeassistant.core import DOMAIN as HASS_DOMAIN, HomeAssistant, callback from homeassistant.core import DOMAIN as HASS_DOMAIN, HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, recorder from homeassistant.helpers import config_validation as cv, recorder
from homeassistant.helpers.device_registry import DeviceRegistry, async_get_registry from homeassistant.helpers.device_registry import (
DeviceEntryType,
DeviceRegistry,
async_get_registry,
)
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -660,7 +663,7 @@ def async_register_addons_in_dev_reg(
model=SupervisorEntityModel.ADDON, model=SupervisorEntityModel.ADDON,
sw_version=addon[ATTR_VERSION], sw_version=addon[ATTR_VERSION],
name=addon[ATTR_NAME], name=addon[ATTR_NAME],
entry_type=ATTR_SERVICE, entry_type=DeviceEntryType.SERVICE,
configuration_url=f"homeassistant://hassio/addon/{addon[ATTR_SLUG]}", configuration_url=f"homeassistant://hassio/addon/{addon[ATTR_SLUG]}",
) )
if manufacturer := addon.get(ATTR_REPOSITORY) or addon.get(ATTR_URL): if manufacturer := addon.get(ATTR_REPOSITORY) or addon.get(ATTR_URL):
@ -679,7 +682,7 @@ def async_register_os_in_dev_reg(
model=SupervisorEntityModel.OS, model=SupervisorEntityModel.OS,
sw_version=os_dict[ATTR_VERSION], sw_version=os_dict[ATTR_VERSION],
name="Home Assistant Operating System", name="Home Assistant Operating System",
entry_type=ATTR_SERVICE, entry_type=DeviceEntryType.SERVICE,
) )
dev_reg.async_get_or_create(config_entry_id=entry_id, **params) dev_reg.async_get_or_create(config_entry_id=entry_id, **params)

View file

@ -766,7 +766,7 @@ class HomeKit:
manufacturer=MANUFACTURER, manufacturer=MANUFACTURER,
name=accessory_friendly_name(self._entry_title, self.driver.accessory), name=accessory_friendly_name(self._entry_title, self.driver.accessory),
model=f"HomeKit {hk_mode_name}", model=f"HomeKit {hk_mode_name}",
entry_type="service", entry_type=device_registry.DeviceEntryType.SERVICE,
) )
@callback @callback

View file

@ -20,6 +20,7 @@ from homeassistant.const import (
SPEED_MILES_PER_HOUR, SPEED_MILES_PER_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -187,7 +188,7 @@ class MetEireannWeather(CoordinatorEntity, WeatherEntity):
"""Device info.""" """Device info."""
return DeviceInfo( return DeviceInfo(
default_name="Forecast", default_name="Forecast",
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN,)}, identifiers={(DOMAIN,)},
manufacturer="Met Éireann", manufacturer="Met Éireann",
model="Forecast", model="Forecast",

View file

@ -8,6 +8,7 @@ from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -96,7 +97,7 @@ class MeteoFranceSensor(CoordinatorEntity, SensorEntity):
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device info.""" """Return the device info."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self.platform.config_entry.unique_id)}, identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
manufacturer=MANUFACTURER, manufacturer=MANUFACTURER,
model=MODEL, model=MODEL,

View file

@ -15,6 +15,7 @@ from homeassistant.components.weather import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_MODE, TEMP_CELSIUS from homeassistant.const import CONF_MODE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -90,7 +91,7 @@ class MeteoFranceWeather(CoordinatorEntity, WeatherEntity):
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device info.""" """Return the device info."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self.platform.config_entry.unique_id)}, identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
manufacturer=MANUFACTURER, manufacturer=MANUFACTURER,
model=MODEL, model=MODEL,

View file

@ -3,6 +3,7 @@ from homeassistant.components.sensor import SensorEntity, SensorEntityDescriptio
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
@ -43,7 +44,7 @@ class MeteoclimaticSensor(CoordinatorEntity, SensorEntity):
def device_info(self): def device_info(self):
"""Return the device info.""" """Return the device info."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self.platform.config_entry.unique_id)}, identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
manufacturer=MANUFACTURER, manufacturer=MANUFACTURER,
model=MODEL, model=MODEL,

View file

@ -5,6 +5,7 @@ from homeassistant.components.weather import WeatherEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
@ -57,7 +58,7 @@ class MeteoclimaticWeather(CoordinatorEntity, WeatherEntity):
def device_info(self): def device_info(self):
"""Return the device info.""" """Return the device info."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self.platform.config_entry.unique_id)}, identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
manufacturer=MANUFACTURER, manufacturer=MANUFACTURER,
model=MODEL, model=MODEL,

View file

@ -39,7 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
manufacturer="Nightscout Foundation", manufacturer="Nightscout Foundation",
name=status.name, name=status.name,
sw_version=status.version, sw_version=status.version,
entry_type="service", entry_type=dr.DeviceEntryType.SERVICE,
) )
hass.config_entries.async_setup_platforms(entry, PLATFORMS) hass.config_entries.async_setup_platforms(entry, PLATFORMS)

View file

@ -12,6 +12,7 @@ from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import debounce from homeassistant.helpers import debounce
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.event import async_track_point_in_utc_time from homeassistant.helpers.event import async_track_point_in_utc_time
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -172,7 +173,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
def device_info(latitude, longitude) -> DeviceInfo: def device_info(latitude, longitude) -> DeviceInfo:
"""Return device registry information.""" """Return device registry information."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, base_unique_id(latitude, longitude))}, identifiers={(DOMAIN, base_unique_id(latitude, longitude))},
manufacturer="National Weather Service", manufacturer="National Weather Service",
name=f"NWS: {latitude}, {longitude}", name=f"NWS: {latitude}, {longitude}",

View file

@ -13,6 +13,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
@ -112,7 +113,7 @@ class OVOEnergyDeviceEntity(OVOEnergyEntity):
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return device information about this OVO Energy instance.""" """Return device information about this OVO Energy instance."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, self._client.account_id)}, identifiers={(DOMAIN, self._client.account_id)},
manufacturer="OVO Energy", manufacturer="OVO Energy",
name=self._client.username, name=self._client.username,

View file

@ -23,6 +23,7 @@ from homeassistant.components.media_player.const import (
from homeassistant.const import STATE_IDLE, STATE_PAUSED, STATE_PLAYING from homeassistant.const import STATE_IDLE, STATE_PAUSED, STATE_PLAYING
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
@ -533,7 +534,7 @@ class PlexMediaPlayer(MediaPlayerEntity):
name="Plex Client Service", name="Plex Client Service",
manufacturer="Plex", manufacturer="Plex",
model="Plex Clients", model="Plex Clients",
entry_type="service", entry_type=DeviceEntryType.SERVICE,
) )
return DeviceInfo( return DeviceInfo(

View file

@ -53,6 +53,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session from homeassistant.helpers.config_entry_oauth2_flow import OAuth2Session
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utc_from_timestamp from homeassistant.util.dt import utc_from_timestamp
@ -267,7 +268,7 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
manufacturer="Spotify AB", manufacturer="Spotify AB",
model=model, model=model,
name=self._name, name=self._name,
entry_type="service", entry_type=DeviceEntryType.SERVICE,
configuration_url="https://open.spotify.com", configuration_url="https://open.spotify.com",
) )

View file

@ -17,6 +17,7 @@ from aiounifi.events import (
from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.components.switch import DOMAIN, SwitchEntity
from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.const import ENTITY_CATEGORY_CONFIG
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_registry import async_entries_for_config_entry from homeassistant.helpers.entity_registry import async_entries_for_config_entry
@ -370,7 +371,7 @@ class UniFiDPIRestrictionSwitch(UniFiBase, SwitchEntity):
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return a service description for device registry.""" """Return a service description for device registry."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, f"unifi_controller_{self._item.site_id}")}, identifiers={(DOMAIN, f"unifi_controller_{self._item.site_id}")},
manufacturer=ATTR_MANUFACTURER, manufacturer=ATTR_MANUFACTURER,
model="UniFi Controller", model="UniFi Controller",

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from yarl import URL from yarl import URL
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -70,7 +71,7 @@ class XboxBaseSensorEntity(CoordinatorEntity):
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return a device description for device registry.""" """Return a device description for device registry."""
return DeviceInfo( return DeviceInfo(
entry_type="service", entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, "xbox_live")}, identifiers={(DOMAIN, "xbox_live")},
manufacturer="Microsoft", manufacturer="Microsoft",
model="Xbox Live", model="Xbox Live",

View file

@ -36,7 +36,7 @@ async def test_list_devices(hass, client, registry):
manufacturer="manufacturer", manufacturer="manufacturer",
model="model", model="model",
via_device=("bridgeid", "0123"), via_device=("bridgeid", "0123"),
entry_type="service", entry_type=helpers_dr.DeviceEntryType.SERVICE,
) )
await client.send_json({"id": 5, "type": "config/device_registry/list"}) await client.send_json({"id": 5, "type": "config/device_registry/list"})
@ -68,7 +68,7 @@ async def test_list_devices(hass, client, registry):
"model": "model", "model": "model",
"name": None, "name": None,
"sw_version": None, "sw_version": None,
"entry_type": "service", "entry_type": helpers_dr.DeviceEntryType.SERVICE,
"via_device_id": dev1, "via_device_id": dev1,
"area_id": None, "area_id": None,
"name_by_user": None, "name_by_user": None,

View file

@ -176,7 +176,7 @@ async def test_gateway_setup(hass, aioclient_mock):
) )
assert gateway_entry.configuration_url == f"http://{HOST}:{PORT}" assert gateway_entry.configuration_url == f"http://{HOST}:{PORT}"
assert gateway_entry.entry_type == "service" assert gateway_entry.entry_type is dr.DeviceEntryType.SERVICE
async def test_gateway_device_configuration_url_when_addon(hass, aioclient_mock): async def test_gateway_device_configuration_url_when_addon(hass, aioclient_mock):

View file

@ -11,6 +11,7 @@ from homeassistant.components.kraken.const import (
DOMAIN, DOMAIN,
) )
from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_START from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_START
from homeassistant.helpers.device_registry import DeviceEntryType
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from .const import ( from .const import (
@ -253,7 +254,7 @@ async def test_sensors_available_after_restart(hass):
identifiers={(DOMAIN, "XBT_USD")}, identifiers={(DOMAIN, "XBT_USD")},
name="XBT USD", name="XBT USD",
manufacturer="Kraken.com", manufacturer="Kraken.com",
entry_type="service", entry_type=DeviceEntryType.SERVICE,
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)

View file

@ -16,6 +16,7 @@ from homeassistant.const import (
DEVICE_CLASS_TIMESTAMP, DEVICE_CLASS_TIMESTAMP,
STATE_UNAVAILABLE, STATE_UNAVAILABLE,
) )
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.util import dt from homeassistant.util import dt
from tests.common import ( from tests.common import (
@ -390,7 +391,7 @@ class TestPicnicSensor(unittest.IsolatedAsyncioTestCase):
) )
assert picnic_service.model == DEFAULT_USER_RESPONSE["user_id"] assert picnic_service.model == DEFAULT_USER_RESPONSE["user_id"]
assert picnic_service.name == "Picnic: Commonstreet 123a" assert picnic_service.name == "Picnic: Commonstreet 123a"
assert picnic_service.entry_type == "service" assert picnic_service.entry_type is DeviceEntryType.SERVICE
async def test_auth_token_is_saved_on_update(self): async def test_auth_token_is_saved_on_update(self):
"""Test that auth-token changes in the session object are reflected by the config entry.""" """Test that auth-token changes in the session object are reflected by the config entry."""

View file

@ -179,7 +179,7 @@ async def test_loading_from_storage(hass, hass_storage):
"model": "model", "model": "model",
"name": "name", "name": "name",
"sw_version": "version", "sw_version": "version",
"entry_type": "service", "entry_type": device_registry.DeviceEntryType.SERVICE,
"area_id": "12345A", "area_id": "12345A",
"name_by_user": "Test Friendly Name", "name_by_user": "Test Friendly Name",
"disabled_by": device_registry.DISABLED_USER, "disabled_by": device_registry.DISABLED_USER,
@ -212,7 +212,7 @@ async def test_loading_from_storage(hass, hass_storage):
assert entry.id == "abcdefghijklm" assert entry.id == "abcdefghijklm"
assert entry.area_id == "12345A" assert entry.area_id == "12345A"
assert entry.name_by_user == "Test Friendly Name" assert entry.name_by_user == "Test Friendly Name"
assert entry.entry_type == "service" assert entry.entry_type is device_registry.DeviceEntryType.SERVICE
assert entry.disabled_by == device_registry.DISABLED_USER assert entry.disabled_by == device_registry.DISABLED_USER
assert isinstance(entry.config_entries, set) assert isinstance(entry.config_entries, set)
assert isinstance(entry.connections, set) assert isinstance(entry.connections, set)

View file

@ -839,7 +839,7 @@ async def test_device_info_called(hass):
"name": "test-name", "name": "test-name",
"sw_version": "test-sw", "sw_version": "test-sw",
"suggested_area": "Heliport", "suggested_area": "Heliport",
"entry_type": "service", "entry_type": dr.DeviceEntryType.SERVICE,
"via_device": ("hue", "via-id"), "via_device": ("hue", "via-id"),
}, },
), ),
@ -863,7 +863,7 @@ async def test_device_info_called(hass):
assert device.identifiers == {("hue", "1234")} assert device.identifiers == {("hue", "1234")}
assert device.configuration_url == "http://192.168.0.100/config" assert device.configuration_url == "http://192.168.0.100/config"
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "abcd")} assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "abcd")}
assert device.entry_type == "service" assert device.entry_type is dr.DeviceEntryType.SERVICE
assert device.manufacturer == "test-manuf" assert device.manufacturer == "test-manuf"
assert device.model == "test-model" assert device.model == "test-model"
assert device.name == "test-name" assert device.name == "test-name"