Home Assistant Unofficial Reference 2024.12.1
binary_sensor.py
Go to the documentation of this file.
1 """Support for binary sensors using Tellstick Net."""
2 
3 from homeassistant.components import binary_sensor
4 from homeassistant.components.binary_sensor import BinarySensorEntity
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.core import HomeAssistant
7 from homeassistant.helpers.dispatcher import async_dispatcher_connect
8 from homeassistant.helpers.entity_platform import AddEntitiesCallback
9 
10 from .const import DOMAIN, TELLDUS_DISCOVERY_NEW
11 from .entity import TelldusLiveEntity
12 
13 
15  hass: HomeAssistant,
16  config_entry: ConfigEntry,
17  async_add_entities: AddEntitiesCallback,
18 ) -> None:
19  """Set up tellduslive sensors dynamically."""
20 
21  async def async_discover_binary_sensor(device_id):
22  """Discover and add a discovered sensor."""
23  client = hass.data[DOMAIN]
24  async_add_entities([TelldusLiveSensor(client, device_id)])
25 
27  hass,
28  TELLDUS_DISCOVERY_NEW.format(binary_sensor.DOMAIN, DOMAIN),
29  async_discover_binary_sensor,
30  )
31 
32 
34  """Representation of a Tellstick sensor."""
35 
36  _attr_name = None
37 
38  @property
39  def is_on(self):
40  """Return true if switch is on."""
41  return self.devicedevice.is_on
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)
Definition: dispatcher.py:103