Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Steam Entity to separate file #91630

Merged
merged 1 commit into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Move Steam Entity to separate file
  • Loading branch information
joostlek committed Apr 18, 2023
commit a4675999f2315c91be22410105ecd8d5dba16032
22 changes: 1 addition & 21 deletions homeassistant/components/steam_online/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
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]
Expand Down Expand Up @@ -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,
)
24 changes: 24 additions & 0 deletions homeassistant/components/steam_online/entity.py
Original file line number Diff line number Diff line change
@@ -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,
)
2 changes: 1 addition & 1 deletion homeassistant/components/steam_online/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from homeassistant.helpers.typing import StateType
from homeassistant.util.dt import utc_from_timestamp

from . import SteamEntity
from .const import (
CONF_ACCOUNTS,
DOMAIN,
Expand All @@ -23,6 +22,7 @@
STEAM_STATUSES,
)
from .coordinator import SteamDataUpdateCoordinator
from .entity import SteamEntity

PARALLEL_UPDATES = 1

Expand Down