-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbinary_sensor.py
30 lines (23 loc) · 1.07 KB
/
binary_sensor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Binary sensor platform for Electrolux Status."""
from homeassistant.components.binary_sensor import BinarySensorEntity
from .entity import ElectroluxStatusEntity
from .const import BINARY_SENSOR
from .const import DOMAIN
async def async_setup_entry(hass, entry, async_add_devices):
"""Setup binary sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
appliances = coordinator.data.get('appliances', None)
if appliances is not None:
for appliance_id, appliance in appliances.found_appliances.items():
async_add_devices(
[
ElectroluxBinarySensor(coordinator, entry, appliance_id, entity.entity_type, entity.attr, entity.source)
for entity in appliance.entities if entity.entity_type == BINARY_SENSOR
]
)
class ElectroluxBinarySensor(ElectroluxStatusEntity, BinarySensorEntity):
"""Electrolux Status binary_sensor class."""
@property
def is_on(self):
"""Return true if the binary_sensor is on."""
return self.get_entity.state