Home Assistant Unofficial Reference 2024.12.1
remote.py
Go to the documentation of this file.
1 """Remote control support for Bravia TV."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Iterable
6 from typing import Any
7 
8 from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers.entity_platform import AddEntitiesCallback
11 
12 from . import BraviaTVConfigEntry
13 from .entity import BraviaTVEntity
14 
15 
17  hass: HomeAssistant,
18  config_entry: BraviaTVConfigEntry,
19  async_add_entities: AddEntitiesCallback,
20 ) -> None:
21  """Set up Bravia TV Remote from a config entry."""
22 
23  coordinator = config_entry.runtime_data
24  unique_id = config_entry.unique_id
25  assert unique_id is not None
26 
27  async_add_entities([BraviaTVRemote(coordinator, unique_id, config_entry.title)])
28 
29 
31  """Representation of a Bravia TV Remote."""
32 
33  _attr_name = None
34 
35  @property
36  def is_on(self) -> bool:
37  """Return true if device is on."""
38  return self.coordinator.is_on
39 
40  async def async_turn_on(self, **kwargs: Any) -> None:
41  """Turn the device on."""
42  await self.coordinator.async_turn_on()
43 
44  async def async_turn_off(self, **kwargs: Any) -> None:
45  """Turn the device off."""
46  await self.coordinator.async_turn_off()
47 
48  async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None:
49  """Send a command to device."""
50  repeats = kwargs[ATTR_NUM_REPEATS]
51  await self.coordinator.async_send_command(command, repeats)
None async_send_command(self, Iterable[str] command, **Any kwargs)
Definition: remote.py:48
None async_setup_entry(HomeAssistant hass, BraviaTVConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: remote.py:20