Home Assistant Unofficial Reference 2024.12.1
remote.py
Go to the documentation of this file.
1 """Support for Keene Electronics IR-IP devices."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Iterable
6 import logging
7 from typing import Any
8 
9 from homeassistant.components import remote
10 from homeassistant.const import CONF_DEVICE, CONF_NAME
11 from homeassistant.core import HomeAssistant
12 from homeassistant.helpers.entity_platform import AddEntitiesCallback
13 from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
14 
15 from . import CONF_REMOTE, DOMAIN
16 
17 _LOGGER = logging.getLogger(__name__)
18 
19 
21  hass: HomeAssistant,
22  config: ConfigType,
23  add_entities: AddEntitiesCallback,
24  discovery_info: DiscoveryInfoType | None = None,
25 ) -> None:
26  """Set up the Kira platform."""
27  if discovery_info:
28  name = discovery_info.get(CONF_NAME)
29  device = discovery_info.get(CONF_DEVICE)
30 
31  kira = hass.data[DOMAIN][CONF_REMOTE][name]
32  add_entities([KiraRemote(device, kira)])
33 
34 
36  """Remote representation used to send commands to a Kira device."""
37 
38  def __init__(self, name, kira):
39  """Initialize KiraRemote class."""
40  _LOGGER.debug("KiraRemote device init started for: %s", name)
41  self._attr_name_attr_name = name
42  self._kira_kira = kira
43 
44  def send_command(self, command: Iterable[str], **kwargs: Any) -> None:
45  """Send a command to one device."""
46  for single_command in command:
47  code_tuple = (single_command, kwargs.get(remote.ATTR_DEVICE))
48  _LOGGER.debug("Sending Command: %s to %s", *code_tuple)
49  self._kira_kira.sendCode(code_tuple)
None send_command(self, Iterable[str] command, **Any kwargs)
Definition: remote.py:44
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)
Definition: remote.py:25