Home Assistant Unofficial Reference 2024.12.1
binary_sensor.py
Go to the documentation of this file.
1 """Support for Goal Zero Yeti Sensors."""
2 
3 from __future__ import annotations
4 
5 from typing import cast
6 
8  BinarySensorDeviceClass,
9  BinarySensorEntity,
10  BinarySensorEntityDescription,
11 )
12 from homeassistant.const import EntityCategory
13 from homeassistant.core import HomeAssistant
14 from homeassistant.helpers.entity_platform import AddEntitiesCallback
15 
16 from .coordinator import GoalZeroConfigEntry
17 from .entity import GoalZeroEntity
18 
19 PARALLEL_UPDATES = 0
20 
21 BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
23  key="backlight",
24  translation_key="backlight",
25  ),
27  key="app_online",
28  translation_key="app_online",
29  device_class=BinarySensorDeviceClass.CONNECTIVITY,
30  entity_category=EntityCategory.DIAGNOSTIC,
31  ),
33  key="isCharging",
34  device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
35  ),
37  key="inputDetected",
38  translation_key="input_detected",
39  device_class=BinarySensorDeviceClass.POWER,
40  ),
41 )
42 
43 
45  hass: HomeAssistant,
46  entry: GoalZeroConfigEntry,
47  async_add_entities: AddEntitiesCallback,
48 ) -> None:
49  """Set up the Goal Zero Yeti sensor."""
51  GoalZeroBinarySensor(entry.runtime_data, description)
52  for description in BINARY_SENSOR_TYPES
53  )
54 
55 
57  """Representation of a Goal Zero Yeti sensor."""
58 
59  @property
60  def is_on(self) -> bool:
61  """Return True if the service is on."""
62  return cast(bool, self._api_api.data[self.entity_descriptionentity_description.key] == 1)
None async_setup_entry(HomeAssistant hass, GoalZeroConfigEntry entry, AddEntitiesCallback async_add_entities)