41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""Binary sensor de disponibilité du proxy Arkteos."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass, BinarySensorEntity
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from . import _get_client
|
|
from .const import DOMAIN
|
|
from .entity import ArkteosEntity
|
|
|
|
|
|
async def async_setup_entry(hass, entry, async_add_entities: AddEntitiesCallback) -> None:
|
|
"""Ajoute l'unique entité de connexion de cette config entry."""
|
|
|
|
client = _get_client(hass, entry)
|
|
if client is None:
|
|
return
|
|
async_add_entities([ArkteosConnectionBinarySensor(client)])
|
|
|
|
|
|
class ArkteosConnectionBinarySensor(ArkteosEntity, BinarySensorEntity):
|
|
"""Expose la disponibilité du flux lu depuis le proxy."""
|
|
|
|
_attr_translation_key = "connection"
|
|
_attr_unique_id = "arkteos_zuran4_connection"
|
|
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
|
|
_attr_device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, "arkteos_zuran4")},
|
|
manufacturer="Arkteos",
|
|
model="Zuran 4",
|
|
name="PAC Arkteos Zuran 4",
|
|
)
|
|
|
|
@property
|
|
def is_on(self) -> bool:
|
|
"""Reflète la disponibilité du client sans effectuer de lecture réseau."""
|
|
|
|
return self._client.available
|