Home Assistant Unofficial Reference 2024.12.1
binary_sensor.py
Go to the documentation of this file.
1 """Support for WeMo binary sensors."""
2 
3 from pywemo import Insight, Maker, StandbyState
4 
5 from homeassistant.components.binary_sensor import BinarySensorEntity
6 from homeassistant.config_entries import ConfigEntry
7 from homeassistant.core import HomeAssistant
8 from homeassistant.helpers.entity_platform import AddEntitiesCallback
9 
10 from . import async_wemo_dispatcher_connect
11 from .coordinator import DeviceCoordinator
12 from .entity import WemoBinaryStateEntity, WemoEntity
13 
14 
16  hass: HomeAssistant,
17  _config_entry: ConfigEntry,
18  async_add_entities: AddEntitiesCallback,
19 ) -> None:
20  """Set up WeMo binary sensors."""
21 
22  async def _discovered_wemo(coordinator: DeviceCoordinator) -> None:
23  """Handle a discovered Wemo device."""
24  if isinstance(coordinator.wemo, Insight):
26  elif isinstance(coordinator.wemo, Maker):
28  else:
29  async_add_entities([WemoBinarySensor(coordinator)])
30 
31  await async_wemo_dispatcher_connect(hass, _discovered_wemo)
32 
33 
35  """Representation a WeMo binary sensor."""
36 
37 
39  """Maker device's sensor port."""
40 
41  _name_suffix = "Sensor"
42  wemo: Maker
43 
44  @property
45  def is_on(self) -> bool:
46  """Return true if the Maker's sensor is pulled low."""
47  return self.wemowemowemo.has_sensor != 0 and self.wemowemowemo.sensor_state == 0
48 
49 
51  """Sensor representing the device connected to the Insight Switch."""
52 
53  _name_suffix = "Device"
54  wemo: Insight
55 
56  @property
57  def is_on(self) -> bool:
58  """Return true device connected to the Insight Switch is on."""
59  return super().is_on and self.wemowemowemo.standby_state == StandbyState.ON
None async_setup_entry(HomeAssistant hass, ConfigEntry _config_entry, AddEntitiesCallback async_add_entities)
None async_wemo_dispatcher_connect(HomeAssistant hass, DispatchCallback dispatch)
Definition: __init__.py:159