Fix access to hass.data in hdmi-cec (#66504)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-02-14 12:43:36 +01:00 committed by Paulus Schoutsen
parent 96cbae5393
commit 5cccac7a19
2 changed files with 8 additions and 8 deletions

View File

@ -26,7 +26,7 @@ from pycec.const import (
from homeassistant.components.media_player import MediaPlayerEntity from homeassistant.components.media_player import MediaPlayerEntity
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
DOMAIN, DOMAIN as MP_DOMAIN,
SUPPORT_NEXT_TRACK, SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE, SUPPORT_PAUSE,
SUPPORT_PLAY_MEDIA, SUPPORT_PLAY_MEDIA,
@ -48,11 +48,11 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ATTR_NEW, CecEntity from . import ATTR_NEW, DOMAIN, CecEntity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ENTITY_ID_FORMAT = DOMAIN + ".{}" ENTITY_ID_FORMAT = MP_DOMAIN + ".{}"
def setup_platform( def setup_platform(
@ -77,7 +77,7 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity):
def __init__(self, device, logical) -> None: def __init__(self, device, logical) -> None:
"""Initialize the HDMI device.""" """Initialize the HDMI device."""
CecEntity.__init__(self, device, logical) CecEntity.__init__(self, device, logical)
self.entity_id = f"{DOMAIN}.hdmi_{hex(self._logical_address)[2:]}" self.entity_id = f"{MP_DOMAIN}.hdmi_{hex(self._logical_address)[2:]}"
def send_keypress(self, key): def send_keypress(self, key):
"""Send keypress to CEC adapter.""" """Send keypress to CEC adapter."""

View File

@ -3,17 +3,17 @@ from __future__ import annotations
import logging import logging
from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ATTR_NEW, CecEntity from . import ATTR_NEW, DOMAIN, CecEntity
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
ENTITY_ID_FORMAT = DOMAIN + ".{}" ENTITY_ID_FORMAT = SWITCH_DOMAIN + ".{}"
def setup_platform( def setup_platform(
@ -38,7 +38,7 @@ class CecSwitchEntity(CecEntity, SwitchEntity):
def __init__(self, device, logical) -> None: def __init__(self, device, logical) -> None:
"""Initialize the HDMI device.""" """Initialize the HDMI device."""
CecEntity.__init__(self, device, logical) CecEntity.__init__(self, device, logical)
self.entity_id = f"{DOMAIN}.hdmi_{hex(self._logical_address)[2:]}" self.entity_id = f"{SWITCH_DOMAIN}.hdmi_{hex(self._logical_address)[2:]}"
def turn_on(self, **kwargs) -> None: def turn_on(self, **kwargs) -> None:
"""Turn device on.""" """Turn device on."""