2020-03-31 18:58:44 +00:00
|
|
|
"""Support for MyQ gateways."""
|
|
|
|
from homeassistant.components.binary_sensor import (
|
|
|
|
DEVICE_CLASS_CONNECTIVITY,
|
2020-04-23 19:57:07 +00:00
|
|
|
BinarySensorEntity,
|
2020-03-31 18:58:44 +00:00
|
|
|
)
|
2021-10-25 05:21:20 +00:00
|
|
|
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
|
2020-03-31 18:58:44 +00:00
|
|
|
|
2021-08-19 01:50:46 +00:00
|
|
|
from . import MyQEntity
|
2020-05-10 18:42:28 +00:00
|
|
|
from .const import DOMAIN, MYQ_COORDINATOR, MYQ_GATEWAY
|
2020-03-31 18:58:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
|
|
|
"""Set up mysq covers."""
|
|
|
|
data = hass.data[DOMAIN][config_entry.entry_id]
|
|
|
|
myq = data[MYQ_GATEWAY]
|
|
|
|
coordinator = data[MYQ_COORDINATOR]
|
|
|
|
|
|
|
|
entities = []
|
|
|
|
|
2021-02-10 20:30:52 +00:00
|
|
|
for device in myq.gateways.values():
|
|
|
|
entities.append(MyQBinarySensorEntity(coordinator, device))
|
2020-03-31 18:58:44 +00:00
|
|
|
|
2021-05-03 04:52:48 +00:00
|
|
|
async_add_entities(entities)
|
2020-03-31 18:58:44 +00:00
|
|
|
|
|
|
|
|
2021-08-19 01:50:46 +00:00
|
|
|
class MyQBinarySensorEntity(MyQEntity, BinarySensorEntity):
|
2020-03-31 18:58:44 +00:00
|
|
|
"""Representation of a MyQ gateway."""
|
|
|
|
|
2021-06-01 19:43:55 +00:00
|
|
|
_attr_device_class = DEVICE_CLASS_CONNECTIVITY
|
2021-10-25 05:21:20 +00:00
|
|
|
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
2021-06-01 19:43:55 +00:00
|
|
|
|
2020-03-31 18:58:44 +00:00
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""Return the name of the garage door if any."""
|
|
|
|
return f"{self._device.name} MyQ Gateway"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_on(self):
|
|
|
|
"""Return if the device is online."""
|
2021-08-19 01:50:46 +00:00
|
|
|
return super().available
|
2020-03-31 18:58:44 +00:00
|
|
|
|
2020-08-30 12:40:00 +00:00
|
|
|
@property
|
|
|
|
def available(self) -> bool:
|
|
|
|
"""Entity is always available."""
|
|
|
|
return True
|