Use runtime_data for elgato (#116614)

This commit is contained in:
Marc Mueller 2024-05-06 19:12:01 +02:00 committed by GitHub
parent 95405ba6bb
commit 8c053a351c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 22 additions and 30 deletions

View file

@ -9,13 +9,12 @@ from typing import Any
from elgato import Elgato, ElgatoError
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from . import ElgatorConfigEntry
from .coordinator import ElgatoData, ElgatoDataUpdateCoordinator
from .entity import ElgatoEntity
@ -53,11 +52,11 @@ SWITCHES = [
async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
entry: ElgatorConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Elgato switches based on a config entry."""
coordinator: ElgatoDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
coordinator = entry.runtime_data
async_add_entities(
ElgatoSwitchEntity(