Home Assistant Unofficial Reference 2024.12.1
binary_sensor.py
Go to the documentation of this file.
1 """Support for Netgear LTE binary sensors."""
2 
3 from __future__ import annotations
4 
6  BinarySensorDeviceClass,
7  BinarySensorEntity,
8  BinarySensorEntityDescription,
9 )
10 from homeassistant.const import EntityCategory
11 from homeassistant.core import HomeAssistant
12 from homeassistant.helpers.entity_platform import AddEntitiesCallback
13 
14 from . import NetgearLTEConfigEntry
15 from .entity import LTEEntity
16 
17 BINARY_SENSORS: tuple[BinarySensorEntityDescription, ...] = (
19  key="roaming",
20  translation_key="roaming",
21  entity_registry_enabled_default=False,
22  entity_category=EntityCategory.DIAGNOSTIC,
23  ),
25  key="wire_connected",
26  translation_key="wire_connected",
27  entity_category=EntityCategory.DIAGNOSTIC,
28  device_class=BinarySensorDeviceClass.CONNECTIVITY,
29  ),
31  key="mobile_connected",
32  translation_key="mobile_connected",
33  entity_category=EntityCategory.DIAGNOSTIC,
34  device_class=BinarySensorDeviceClass.CONNECTIVITY,
35  ),
36 )
37 
38 
40  hass: HomeAssistant,
41  entry: NetgearLTEConfigEntry,
42  async_add_entities: AddEntitiesCallback,
43 ) -> None:
44  """Set up the Netgear LTE binary sensor."""
46  NetgearLTEBinarySensor(entry, description) for description in BINARY_SENSORS
47  )
48 
49 
51  """Netgear LTE binary sensor entity."""
52 
53  @property
54  def is_on(self):
55  """Return true if the binary sensor is on."""
56  return getattr(self.coordinator.data, self.entity_descriptionentity_description.key)
None async_setup_entry(HomeAssistant hass, NetgearLTEConfigEntry entry, AddEntitiesCallback async_add_entities)