1 """Add support for the Xiaomi TVs."""
3 from __future__
import annotations
8 import voluptuous
as vol
11 PLATFORM_SCHEMA
as MEDIA_PLAYER_PLATFORM_SCHEMA,
13 MediaPlayerEntityFeature,
22 DEFAULT_NAME =
"Xiaomi TV"
24 _LOGGER = logging.getLogger(__name__)
27 PLATFORM_SCHEMA = MEDIA_PLAYER_PLATFORM_SCHEMA.extend(
29 vol.Optional(CONF_HOST): cv.string,
30 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
38 add_entities: AddEntitiesCallback,
39 discovery_info: DiscoveryInfoType |
None =
None,
41 """Set up the Xiaomi TV platform."""
44 host = config.get(CONF_HOST)
45 name = config.get(CONF_NAME)
49 if not pymitv.Discover().check_ip(host):
50 _LOGGER.error(
"Could not find Xiaomi TV with specified IP: %s", host)
60 """Represent the Xiaomi TV for Home Assistant."""
62 _attr_assumed_state =
True
63 _attr_supported_features = (
64 MediaPlayerEntityFeature.VOLUME_STEP
65 | MediaPlayerEntityFeature.TURN_ON
66 | MediaPlayerEntityFeature.TURN_OFF
70 """Receive IP address and name to construct class."""
73 self.
_tv_tv = pymitv.TV(ip)
79 """Instruct the TV to turn sleep.
81 This is done instead of turning off,
82 because the TV won't accept any input when turned off. Thus, the user
83 would be unable to turn the TV back on, unless it's done manually.
91 """Wake the TV back up from sleep."""
98 """Increase volume by one."""
102 """Decrease volume by one."""
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)