1
mirror of https://github.com/home-assistant/core synced 2024-09-18 19:55:20 +02:00
ha-core/homeassistant/components/elgato/entity.py
2022-01-25 20:29:18 +01:00

30 lines
1012 B
Python

"""Base entity for the Elgato integration."""
from __future__ import annotations
from elgato import Elgato, Info
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, format_mac
from homeassistant.helpers.entity import DeviceInfo, Entity
from .const import DOMAIN
class ElgatoEntity(Entity):
"""Defines an Elgato entity."""
def __init__(self, client: Elgato, info: Info, mac: str | None) -> None:
"""Initialize an Elgato entity."""
self.client = client
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, info.serial_number)},
manufacturer="Elgato",
model=info.product_name,
name=info.display_name,
sw_version=f"{info.firmware_version} ({info.firmware_build_number})",
hw_version=str(info.hardware_board_type),
)
if mac is not None:
self._attr_device_info["connections"] = {
(CONNECTION_NETWORK_MAC, format_mac(mac))
}