mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Move Steam Entity to separate file (#91630)
This commit is contained in:
parent
88f5f04be8
commit
162c36f108
@ -4,13 +4,10 @@ from __future__ import annotations
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
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.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.helpers.typing import ConfigType
|
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
|
from .coordinator import SteamDataUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.SENSOR]
|
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):
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
hass.data[DOMAIN].pop(entry.entry_id)
|
||||||
return unload_ok
|
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,
|
|
||||||
)
|
|
||||||
|
24
homeassistant/components/steam_online/entity.py
Normal file
24
homeassistant/components/steam_online/entity.py
Normal file
@ -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,
|
||||||
|
)
|
@ -12,7 +12,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
from homeassistant.util.dt import utc_from_timestamp
|
from homeassistant.util.dt import utc_from_timestamp
|
||||||
|
|
||||||
from . import SteamEntity
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_ACCOUNTS,
|
CONF_ACCOUNTS,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -23,6 +22,7 @@ from .const import (
|
|||||||
STEAM_STATUSES,
|
STEAM_STATUSES,
|
||||||
)
|
)
|
||||||
from .coordinator import SteamDataUpdateCoordinator
|
from .coordinator import SteamDataUpdateCoordinator
|
||||||
|
from .entity import SteamEntity
|
||||||
|
|
||||||
PARALLEL_UPDATES = 1
|
PARALLEL_UPDATES = 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user