Home Assistant Unofficial Reference 2024.12.1
binary_sensor.py
Go to the documentation of this file.
1 """Support for Aqualink temperature sensors."""
2 
3 from __future__ import annotations
4 
5 from iaqualink.device import AqualinkBinarySensor
6 
8  DOMAIN as BINARY_SENSOR_DOMAIN,
9  BinarySensorDeviceClass,
10  BinarySensorEntity,
11 )
12 from homeassistant.config_entries import ConfigEntry
13 from homeassistant.core import HomeAssistant
14 from homeassistant.helpers.entity_platform import AddEntitiesCallback
15 
16 from .const import DOMAIN as AQUALINK_DOMAIN
17 from .entity import AqualinkEntity
18 
19 PARALLEL_UPDATES = 0
20 
21 
23  hass: HomeAssistant,
24  config_entry: ConfigEntry,
25  async_add_entities: AddEntitiesCallback,
26 ) -> None:
27  """Set up discovered binary sensors."""
29  (
31  for dev in hass.data[AQUALINK_DOMAIN][BINARY_SENSOR_DOMAIN]
32  ),
33  True,
34  )
35 
36 
38  """Representation of a binary sensor."""
39 
40  def __init__(self, dev: AqualinkBinarySensor) -> None:
41  """Initialize AquaLink binary sensor."""
42  super().__init__(dev)
43  self._attr_name_attr_name = dev.label
44  if dev.label == "Freeze Protection":
45  self._attr_device_class_attr_device_class = BinarySensorDeviceClass.COLD
46 
47  @property
48  def is_on(self) -> bool:
49  """Return whether the binary sensor is on or not."""
50  return self.devdev.is_on