Add iaqualink binary sensor and unique_id (#26616)

* Add binary_platform to iaqualink integration, add unique_id

* Revert Mixin changes, move self.dev to AqualinkEntity

* Style fixes
This commit is contained in:
Florent Thoumie authored and Martin Hjelmare committed 2019-09-14 07:05:47 +02:00
1 parent bca7363a80
commit a71cd6e90e
7 files changed
+74 -31

No files matched your search

@@ -0,0 +1,48 @@
"""Support for Aqualink temperature sensors."""
import logging
from homeassistant.components.binary_sensor import (
BinarySensorDevice,
DEVICE_CLASS_COLD,
DOMAIN,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType
from . import AqualinkEntity
from .const import DOMAIN as AQUALINK_DOMAIN
_LOGGER = logging.getLogger(__name__)
PARALLEL_UPDATES = 0
async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) -> None:
"""Set up discovered binary sensors."""
devs = []
for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]:
devs.append(HassAqualinkBinarySensor(dev))
async_add_entities(devs, True)
class HassAqualinkBinarySensor(AqualinkEntity, BinarySensorDevice):
"""Representation of a binary sensor."""
@property
def name(self) -> str:
"""Return the name of the binary sensor."""
return self.dev.label
@property
def is_on(self) -> bool:
"""Return whether the binary sensor is on or not."""
return self.dev.is_on
@property
def device_class(self) -> str:
"""Return the class of the binary sensor."""
if self.name == "Freeze Protection":
return DEVICE_CLASS_COLD
return None