From 162c36f108684dbbaafe836e6a3d9d4f7dca0d3b Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Wed, 19 Apr 2023 14:14:59 +0200 Subject: [PATCH] Move Steam Entity to separate file (#91630) --- .../components/steam_online/__init__.py | 22 +---------------- .../components/steam_online/entity.py | 24 +++++++++++++++++++ .../components/steam_online/sensor.py | 2 +- 3 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 homeassistant/components/steam_online/entity.py diff --git a/homeassistant/components/steam_online/__init__.py b/homeassistant/components/steam_online/__init__.py index 2629962565b..2b1b3223212 100644 --- a/homeassistant/components/steam_online/__init__.py +++ b/homeassistant/components/steam_online/__init__.py @@ -4,13 +4,10 @@ from __future__ import annotations from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from homeassistant.helpers.device_registry import DeviceEntryType -from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue from homeassistant.helpers.typing import ConfigType -from homeassistant.helpers.update_coordinator import CoordinatorEntity -from .const import DEFAULT_NAME, DOMAIN +from .const import DOMAIN from .coordinator import SteamDataUpdateCoordinator PLATFORMS = [Platform.SENSOR] @@ -47,20 +44,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS): hass.data[DOMAIN].pop(entry.entry_id) return unload_ok - - -class SteamEntity(CoordinatorEntity[SteamDataUpdateCoordinator]): - """Representation of a Steam entity.""" - - _attr_attribution = "Data provided by Steam" - - def __init__(self, coordinator: SteamDataUpdateCoordinator) -> None: - """Initialize a Steam entity.""" - super().__init__(coordinator) - self._attr_device_info = DeviceInfo( - configuration_url="https://store.steampowered.com", - entry_type=DeviceEntryType.SERVICE, - identifiers={(DOMAIN, coordinator.config_entry.entry_id)}, - manufacturer=DEFAULT_NAME, - name=DEFAULT_NAME, - ) diff --git a/homeassistant/components/steam_online/entity.py b/homeassistant/components/steam_online/entity.py new file mode 100644 index 00000000000..364f2e72328 --- /dev/null +++ b/homeassistant/components/steam_online/entity.py @@ -0,0 +1,24 @@ +"""Entity classes for the Steam integration.""" +from homeassistant.helpers.device_registry import DeviceEntryType +from homeassistant.helpers.entity import DeviceInfo +from homeassistant.helpers.update_coordinator import CoordinatorEntity + +from .const import DEFAULT_NAME, DOMAIN +from .coordinator import SteamDataUpdateCoordinator + + +class SteamEntity(CoordinatorEntity[SteamDataUpdateCoordinator]): + """Representation of a Steam entity.""" + + _attr_attribution = "Data provided by Steam" + + def __init__(self, coordinator: SteamDataUpdateCoordinator) -> None: + """Initialize a Steam entity.""" + super().__init__(coordinator) + self._attr_device_info = DeviceInfo( + configuration_url="https://store.steampowered.com", + entry_type=DeviceEntryType.SERVICE, + identifiers={(DOMAIN, coordinator.config_entry.entry_id)}, + manufacturer=DEFAULT_NAME, + name=DEFAULT_NAME, + ) diff --git a/homeassistant/components/steam_online/sensor.py b/homeassistant/components/steam_online/sensor.py index 10e507775d0..d3ae69e2517 100644 --- a/homeassistant/components/steam_online/sensor.py +++ b/homeassistant/components/steam_online/sensor.py @@ -12,7 +12,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType from homeassistant.util.dt import utc_from_timestamp -from . import SteamEntity from .const import ( CONF_ACCOUNTS, DOMAIN, @@ -23,6 +22,7 @@ from .const import ( STEAM_STATUSES, ) from .coordinator import SteamDataUpdateCoordinator +from .entity import SteamEntity PARALLEL_UPDATES = 1