Add device class for roku devices (#39627)
* add tv device class for roku tvs * Update test_media_player.py * Update test_media_player.py * Update media_player.py * Update test_media_player.py * Update media_player.py * Update test_media_player.py * Update test_media_player.py * Update media_player.pypull/39632/head
parent
a87fedc0af
commit
77f5fb765b
|
@ -1,10 +1,14 @@
|
|||
"""Support for the Roku media player."""
|
||||
import logging
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerEntity
|
||||
from homeassistant.components.media_player import (
|
||||
DEVICE_CLASS_RECEIVER,
|
||||
DEVICE_CLASS_TV,
|
||||
MediaPlayerEntity,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_APP,
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
|
@ -90,6 +94,14 @@ class RokuMediaPlayer(RokuEntity, MediaPlayerEntity):
|
|||
"""Return the unique ID for this entity."""
|
||||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_class(self) -> Optional[str]:
|
||||
"""Return the class of this device."""
|
||||
if self.coordinator.data.info.device_type == "tv":
|
||||
return DEVICE_CLASS_TV
|
||||
|
||||
return DEVICE_CLASS_RECEIVER
|
||||
|
||||
@property
|
||||
def state(self) -> str:
|
||||
"""Return the state of the device."""
|
||||
|
|
|
@ -3,6 +3,7 @@ from datetime import timedelta
|
|||
|
||||
from rokuecp import RokuError
|
||||
|
||||
from homeassistant.components.media_player import DEVICE_CLASS_RECEIVER, DEVICE_CLASS_TV
|
||||
from homeassistant.components.media_player.const import (
|
||||
ATTR_APP_ID,
|
||||
ATTR_APP_NAME,
|
||||
|
@ -77,6 +78,7 @@ async def test_setup(
|
|||
|
||||
assert hass.states.get(MAIN_ENTITY_ID)
|
||||
assert main
|
||||
assert main.device_class == DEVICE_CLASS_RECEIVER
|
||||
assert main.unique_id == UPNP_SERIAL
|
||||
|
||||
|
||||
|
@ -108,6 +110,7 @@ async def test_tv_setup(
|
|||
|
||||
assert hass.states.get(TV_ENTITY_ID)
|
||||
assert tv
|
||||
assert tv.device_class == DEVICE_CLASS_TV
|
||||
assert tv.unique_id == TV_SERIAL
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue