Esempio n. 1
0
    def process_entities_callback(hass, config_entry):
        data = hass.data[DOMAIN][config_entry.entry_id]
        coordinator = data[COORDINATOR]
        entities = []
        entity = PfSenseCarpStatusBinarySensor(
            config_entry,
            coordinator,
            BinarySensorEntityDescription(
                key="carp.status",
                name="CARP Status",
                # native_unit_of_measurement=native_unit_of_measurement,
                icon="mdi:gauge",
                # state_class=state_class,
                # entity_category=entity_category,
            ),
            False,
        )
        entities.append(entity)

        entity = PfSensePendingNoticesPresentBinarySensor(
            config_entry,
            coordinator,
            BinarySensorEntityDescription(
                key=f"notices.pending_notices_present",
                name="Pending Notices Present",
                # native_unit_of_measurement=native_unit_of_measurement,
                icon="mdi:alert",
                # state_class=state_class,
                # entity_category=entity_category,
            ),
            True,
        )
        entities.append(entity)

        return entities
Esempio n. 2
0
class DeebotMopAttachedBinarySensor(DeebotEntity, BinarySensorEntity):  # type: ignore
    """Deebot mop attached binary sensor."""

    entity_description = BinarySensorEntityDescription(
        key="mop_attached",
        entity_registry_enabled_default=False,
        entity_category=EntityCategory.DIAGNOSTIC,
    )

    @property
    def icon(self) -> Optional[str]:
        """Return the icon to use in the frontend, if any."""
        return "mdi:water" if self.is_on else "mdi:water-off"

    async def async_added_to_hass(self) -> None:
        """Set up the event listeners now that hass is ready."""
        await super().async_added_to_hass()

        async def on_event(event: WaterInfoEvent) -> None:
            self._attr_is_on = event.mop_attached
            self.async_write_ha_state()

        listener: EventListener = self._vacuum_bot.events.subscribe(
            WaterInfoEvent, on_event
        )
        self.async_on_remove(listener.unsubscribe)
Esempio n. 3
0
 def get_sensor_description(type_string: str,
                            device_class: str | None = None):
     description = SENSOR_TYPES_DICT.get(type_string)
     if description is None:
         description = BinarySensorEntityDescription(key=type_string)
     if device_class:
         description = replace(description, device_class=device_class)
     return description
Esempio n. 4
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up the UptimeRobot binary_sensors."""
    coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
    async_add_entities([
        UptimeRobotBinarySensor(
            coordinator,
            BinarySensorEntityDescription(
                key=str(monitor.id),
                name=monitor.friendly_name,
                device_class=BinarySensorDeviceClass.CONNECTIVITY,
            ),
            monitor=monitor,
        ) for monitor in coordinator.data
    ], )
async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up a config entry."""
    coordinator: AmberUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]

    entities: list = []
    price_spike_description = BinarySensorEntityDescription(
        key="price_spike",
        name=f"{entry.title} - Price Spike",
    )
    entities.append(AmberPriceSpikeBinarySensor(coordinator, price_spike_description))
    async_add_entities(entities)
Esempio n. 6
0
async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
    """Set entry for Alarm Panel."""

    stl_hub: STLAlarmHub = hass.data[DOMAIN][entry.entry_id]["api"]
    coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][
        "coordinator"
    ]
    add_entities: list = []
    devices: list = await stl_hub.get_door_sensors()
    for device in devices:
        devicename = await stl_hub.get_door_sensor_names(device)
        description = BinarySensorEntityDescription(
            key=device, name=devicename, device_class=DEVICE_CLASS_DOOR
        )
        add_entities.append(STLBinarySensor(stl_hub, coordinator, description))
    async_add_entities(add_entities)
Esempio n. 7
0
async def async_setup_platform(hass: HomeAssistant,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up the Uptime Robot binary_sensors."""
    uptime_robot_api = UptimeRobot()
    api_key = config[CONF_API_KEY]

    def api_wrapper():
        return uptime_robot_api.getMonitors(api_key)

    async def async_update_data():
        """Fetch data from API UptimeRobot API."""
        async with async_timeout.timeout(10):
            monitors = await hass.async_add_executor_job(api_wrapper)
            if not monitors or monitors.get("stat") != "ok":
                raise UpdateFailed("Error communicating with Uptime Robot API")
            return monitors

    coordinator = DataUpdateCoordinator(
        hass,
        _LOGGER,
        name="uptimerobot",
        update_method=async_update_data,
        update_interval=timedelta(seconds=60),
    )

    await coordinator.async_refresh()

    if not coordinator.data or coordinator.data.get("stat") != "ok":
        _LOGGER.error("Error connecting to Uptime Robot")
        raise PlatformNotReady()

    async_add_entities([
        UptimeRobotBinarySensor(
            coordinator,
            BinarySensorEntityDescription(
                key=monitor["id"],
                name=monitor["friendly_name"],
                device_class=DEVICE_CLASS_CONNECTIVITY,
            ),
            target=monitor["url"],
        ) for monitor in coordinator.data["monitors"]
    ], )
Esempio n. 8
0
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .common import FritzBoxBaseEntity, FritzBoxTools
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key="is_connected",
        name="Connection",
        device_class=DEVICE_CLASS_CONNECTIVITY,
    ),
    BinarySensorEntityDescription(
        key="is_linked",
        name="Link",
        device_class=DEVICE_CLASS_PLUG,
    ),
    BinarySensorEntityDescription(
        key="firmware_update",
        name="Firmware Update",
        device_class=DEVICE_CLASS_UPDATE,
    ),
)

Esempio n. 9
0
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import (
    DEFAULT_BRAND,
    DOMAIN,
    TYPE_BATTERY,
    TYPE_CAMERA_ARMED,
    TYPE_MOTION_DETECTED,
)

BINARY_SENSORS_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key=TYPE_BATTERY,
        name="Battery",
        device_class=BinarySensorDeviceClass.BATTERY,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
    BinarySensorEntityDescription(
        key=TYPE_CAMERA_ARMED,
        name="Camera Armed",
    ),
    BinarySensorEntityDescription(
        key=TYPE_MOTION_DETECTED,
        name="Motion Detected",
        device_class=BinarySensorDeviceClass.MOTION,
    ),
)


async def async_setup_entry(hass: HomeAssistant, config: ConfigEntry,
Esempio n. 10
0
from homeassistant.components.bluetooth.passive_update_processor import (
    PassiveBluetoothDataProcessor,
    PassiveBluetoothDataUpdate,
    PassiveBluetoothProcessorCoordinator,
    PassiveBluetoothProcessorEntity,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN
from .device import device_key_to_bluetooth_entity_key, sensor_device_info_to_hass

BINARY_SENSOR_DESCRIPTIONS = {
    QingpingBinarySensorDeviceClass.MOTION:
    BinarySensorEntityDescription(
        key=QingpingBinarySensorDeviceClass.MOTION,
        device_class=BinarySensorDeviceClass.MOTION,
    ),
    QingpingBinarySensorDeviceClass.LIGHT:
    BinarySensorEntityDescription(
        key=QingpingBinarySensorDeviceClass.LIGHT,
        device_class=BinarySensorDeviceClass.LIGHT,
    ),
    QingpingBinarySensorDeviceClass.DOOR:
    BinarySensorEntityDescription(
        key=QingpingBinarySensorDeviceClass.DOOR,
        device_class=BinarySensorDeviceClass.DOOR,
    ),
}


def sensor_update_to_bluetooth_data_update(
Esempio n. 11
0
    Fire,
    GenericFlag,
    OpenClose,
    Presence,
    Vibration,
    Water,
)

ATTR_ORIENTATION = "orientation"
ATTR_TILTANGLE = "tiltangle"
ATTR_VIBRATIONSTRENGTH = "vibrationstrength"

ENTITY_DESCRIPTIONS = {
    CarbonMonoxide:
    BinarySensorEntityDescription(
        key="carbonmonoxide",
        device_class=BinarySensorDeviceClass.GAS,
    ),
    Fire:
    BinarySensorEntityDescription(
        key="fire",
        device_class=BinarySensorDeviceClass.SMOKE,
    ),
    OpenClose:
    BinarySensorEntityDescription(
        key="openclose",
        device_class=BinarySensorDeviceClass.OPENING,
    ),
    Presence:
    BinarySensorEntityDescription(
        key="presence",
        device_class=BinarySensorDeviceClass.MOTION,
class AugustRequiredKeysMixin:
    """Mixin for required keys."""

    value_fn: Callable[[AugustData, DoorbellDetail], bool]
    is_time_based: bool


@dataclass
class AugustBinarySensorEntityDescription(
    BinarySensorEntityDescription, AugustRequiredKeysMixin
):
    """Describes August binary_sensor entity."""


SENSOR_TYPE_DOOR = BinarySensorEntityDescription(
    key="door_open",
    name="Open",
)


SENSOR_TYPES_DOORBELL: tuple[AugustBinarySensorEntityDescription, ...] = (
    AugustBinarySensorEntityDescription(
        key="doorbell_ding",
        name="Ding",
        device_class=DEVICE_CLASS_OCCUPANCY,
        value_fn=_retrieve_ding_state,
        is_time_based=True,
    ),
    AugustBinarySensorEntityDescription(
        key="doorbell_motion",
        name="Motion",
        device_class=DEVICE_CLASS_MOTION,
Esempio n. 13
0
from .const import (
    DATA_CLIENT,
    DATA_PROTECTION_WINDOW,
    DOMAIN,
    LOGGER,
    TYPE_PROTECTION_WINDOW,
)

ATTR_PROTECTION_WINDOW_ENDING_TIME = "end_time"
ATTR_PROTECTION_WINDOW_ENDING_UV = "end_uv"
ATTR_PROTECTION_WINDOW_STARTING_TIME = "start_time"
ATTR_PROTECTION_WINDOW_STARTING_UV = "start_uv"

BINARY_SENSOR_DESCRIPTION_PROTECTION_WINDOW = BinarySensorEntityDescription(
    key=TYPE_PROTECTION_WINDOW,
    name="Protection Window",
    icon="mdi:sunglasses",
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up an OpenUV sensor based on a config entry."""
    openuv = hass.data[DOMAIN][entry.entry_id][DATA_CLIENT]
    async_add_entities([
        OpenUvBinarySensor(openuv, BINARY_SENSOR_DESCRIPTION_PROTECTION_WINDOW)
    ])


class OpenUvBinarySensor(OpenUvEntity, BinarySensorEntity):
    """Define a binary sensor for OpenUV."""
Esempio n. 14
0
                self.handle_hardware_status_update,
            )
        )

        self.async_on_remove(
            async_dispatcher_connect(
                self.hass,
                f"{SERVER_UNAVAILABLE}-{self._user_id}",
                self.handle_server_unavailable,
            )
        )


SENSOR_TYPE = BinarySensorEntityDescription(
    key=ATTR_BATTERY_CHARGING,
    name="Battery Charging",
    device_class=DEVICE_CLASS_BATTERY_CHARGING,
)


async def async_setup_entry(hass, entry, async_add_entities):
    """Set up Tractive device trackers."""
    client = hass.data[DOMAIN][entry.entry_id][CLIENT]
    trackables = hass.data[DOMAIN][entry.entry_id][TRACKABLES]

    entities = []

    for item in trackables:
        if item.tracker_details["model_number"] not in TRACKERS_WITH_BUILTIN_BATTERY:
            continue
        entities.append(
Esempio n. 15
0
    BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DATA_COORDINATOR, DOMAIN
from .coordinator import EzvizDataUpdateCoordinator
from .entity import EzvizEntity

PARALLEL_UPDATES = 1

BINARY_SENSOR_TYPES: dict[str, BinarySensorEntityDescription] = {
    "Motion_Trigger":
    BinarySensorEntityDescription(
        key="Motion_Trigger",
        device_class=BinarySensorDeviceClass.MOTION,
    ),
    "alarm_schedules_enabled":
    BinarySensorEntityDescription(key="alarm_schedules_enabled"),
    "encrypted":
    BinarySensorEntityDescription(key="encrypted"),
    "upgrade_available":
    BinarySensorEntityDescription(
        key="upgrade_available",
        device_class=BinarySensorDeviceClass.UPDATE,
    ),
}


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
Esempio n. 16
0
    BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .common import FritzBoxBaseEntity, FritzBoxTools
from .const import DOMAIN

_LOGGER = logging.getLogger(__name__)

SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key="is_connected",
        name="Connection",
        device_class=BinarySensorDeviceClass.CONNECTIVITY,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
    BinarySensorEntityDescription(
        key="is_linked",
        name="Link",
        device_class=BinarySensorDeviceClass.PLUG,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
    BinarySensorEntityDescription(
        key="firmware_update",
        name="Firmware Update",
        device_class=BinarySensorDeviceClass.UPDATE,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from . import YetiEntity
from .const import DATA_KEY_API, DATA_KEY_COORDINATOR, DOMAIN

PARALLEL_UPDATES = 0

BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key="backlight",
        name="Backlight",
        icon="mdi:clock-digital",
    ),
    BinarySensorEntityDescription(
        key="app_online",
        name="App Online",
        device_class=BinarySensorDeviceClass.CONNECTIVITY,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
    BinarySensorEntityDescription(
        key="isCharging",
        name="Charging",
        device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
    ),
    BinarySensorEntityDescription(
        key="inputDetected",
# Mappings for property sensors
PROPERTY_SENSOR_MAPPINGS: dict[str, PropertyZWaveJSEntityDescription] = {
    DOOR_STATUS_PROPERTY:
    PropertyZWaveJSEntityDescription(
        key=DOOR_STATUS_PROPERTY,
        on_states=("open", ),
        device_class=DEVICE_CLASS_DOOR,
    ),
}

# Mappings for boolean sensors
BOOLEAN_SENSOR_MAPPINGS: dict[str, BinarySensorEntityDescription] = {
    CommandClass.BATTERY:
    BinarySensorEntityDescription(
        key=str(CommandClass.BATTERY),
        device_class=DEVICE_CLASS_BATTERY,
        entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
    ),
}


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up Z-Wave binary sensor from config entry."""
    client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

    @callback
    def async_add_binary_sensor(info: ZwaveDiscoveryInfo) -> None:
Esempio n. 19
0
    CONF_UID,
    DATA_COORDINATOR,
    DATA_COORDINATOR_PAIRED_SENSOR,
    DOMAIN,
    SIGNAL_PAIRED_SENSOR_COORDINATOR_ADDED,
)

ATTR_CONNECTED_CLIENTS = "connected_clients"

SENSOR_KIND_AP_INFO = "ap_enabled"
SENSOR_KIND_LEAK_DETECTED = "leak_detected"
SENSOR_KIND_MOVED = "moved"

SENSOR_DESCRIPTION_AP_ENABLED = BinarySensorEntityDescription(
    key=SENSOR_KIND_AP_INFO,
    name="Onboard AP Enabled",
    device_class=BinarySensorDeviceClass.CONNECTIVITY,
    entity_category=EntityCategory.DIAGNOSTIC,
)
SENSOR_DESCRIPTION_LEAK_DETECTED = BinarySensorEntityDescription(
    key=SENSOR_KIND_LEAK_DETECTED,
    name="Leak Detected",
    device_class=BinarySensorDeviceClass.MOISTURE,
)
SENSOR_DESCRIPTION_MOVED = BinarySensorEntityDescription(
    key=SENSOR_KIND_MOVED,
    name="Recently Moved",
    device_class=BinarySensorDeviceClass.MOVING,
    entity_category=EntityCategory.DIAGNOSTIC,
)

PAIRED_SENSOR_DESCRIPTIONS = (
Esempio n. 20
0
    DATA_COORDINATOR,
    DATA_COORDINATOR_PAIRED_SENSOR,
    DATA_UNSUB_DISPATCHER_CONNECT,
    DOMAIN,
    SIGNAL_PAIRED_SENSOR_COORDINATOR_ADDED,
)

ATTR_CONNECTED_CLIENTS = "connected_clients"

SENSOR_KIND_AP_INFO = "ap_enabled"
SENSOR_KIND_LEAK_DETECTED = "leak_detected"
SENSOR_KIND_MOVED = "moved"

SENSOR_DESCRIPTION_AP_ENABLED = BinarySensorEntityDescription(
    key=SENSOR_KIND_AP_INFO,
    name="Onboard AP Enabled",
    device_class=DEVICE_CLASS_CONNECTIVITY,
)
SENSOR_DESCRIPTION_LEAK_DETECTED = BinarySensorEntityDescription(
    key=SENSOR_KIND_LEAK_DETECTED,
    name="Leak Detected",
    device_class=DEVICE_CLASS_MOISTURE,
)
SENSOR_DESCRIPTION_MOVED = BinarySensorEntityDescription(
    key=SENSOR_KIND_MOVED,
    name="Recently Moved",
    device_class=DEVICE_CLASS_MOVING,
)

PAIRED_SENSOR_DESCRIPTIONS = (
    SENSOR_DESCRIPTION_LEAK_DETECTED,
Esempio n. 21
0
from __future__ import annotations

from homeassistant.components.binary_sensor import (
    BinarySensorDeviceClass,
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.const import CONF_EMAIL

from . import PoolSenseEntity
from .const import DOMAIN

BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key="pH Status",
        name="pH Status",
        device_class=BinarySensorDeviceClass.PROBLEM,
    ),
    BinarySensorEntityDescription(
        key="Chlorine Status",
        name="Chlorine Status",
        device_class=BinarySensorDeviceClass.PROBLEM,
    ),
)


async def async_setup_entry(hass, config_entry, async_add_entities):
    """Defer sensor setup to the shared sensor module."""
    coordinator = hass.data[DOMAIN][config_entry.entry_id]

    entities = [
Esempio n. 22
0
SENSOR_KIND_AP_INFO = "ap_enabled"
SENSOR_KIND_LEAK_DETECTED = "leak_detected"
SENSOR_KIND_MOVED = "moved"


@dataclass
class ValveControllerBinarySensorDescription(BinarySensorEntityDescription,
                                             ValveControllerEntityDescription):
    """Describe a Guardian valve controller binary sensor."""


PAIRED_SENSOR_DESCRIPTIONS = (
    BinarySensorEntityDescription(
        key=SENSOR_KIND_LEAK_DETECTED,
        name="Leak detected",
        device_class=BinarySensorDeviceClass.MOISTURE,
    ),
    BinarySensorEntityDescription(
        key=SENSOR_KIND_MOVED,
        name="Recently moved",
        device_class=BinarySensorDeviceClass.MOVING,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
)

VALVE_CONTROLLER_DESCRIPTIONS = (
    ValveControllerBinarySensorDescription(
        key=SENSOR_KIND_LEAK_DETECTED,
        name="Leak detected",
        device_class=BinarySensorDeviceClass.MOISTURE,
Esempio n. 23
0
# Mappings for property sensors
PROPERTY_SENSOR_MAPPINGS: dict[str, PropertyZWaveJSEntityDescription] = {
    DOOR_STATUS_PROPERTY:
    PropertyZWaveJSEntityDescription(
        key=DOOR_STATUS_PROPERTY,
        on_states=("open", ),
        device_class=BinarySensorDeviceClass.DOOR,
    ),
}

# Mappings for boolean sensors
BOOLEAN_SENSOR_MAPPINGS: dict[int, BinarySensorEntityDescription] = {
    CommandClass.BATTERY:
    BinarySensorEntityDescription(
        key=str(CommandClass.BATTERY),
        device_class=BinarySensorDeviceClass.BATTERY,
        entity_category=EntityCategory.DIAGNOSTIC,
    ),
}


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up Z-Wave binary sensor from config entry."""
    client: ZwaveClient = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]

    @callback
    def async_add_binary_sensor(info: ZwaveDiscoveryInfo) -> None:
Esempio n. 24
0
"""Fully Kiosk Browser sensor."""
from homeassistant.components.binary_sensor import (
    BinarySensorDeviceClass,
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DOMAIN

SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(key="kioskMode", name="Kiosk Mode"),
    BinarySensorEntityDescription(
        key="plugged",
        name="Plugged In",
        device_class=BinarySensorDeviceClass.PLUG,
    ),
    BinarySensorEntityDescription(
        key="isDeviceAdmin",
        name="Device Admin",
    ),
)


async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up the Fully Kiosk Browser sensor."""
    coordinator = hass.data[DOMAIN][config_entry.entry_id]

    sensors = [
        FullyBinarySensor(coordinator, sensor) for sensor in SENSOR_TYPES
        if sensor.key in coordinator.data
Esempio n. 25
0
from homeassistant.components.binary_sensor import (
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import event
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.dt as dt_util

from . import DOMAIN

BINARY_SENSORS = BinarySensorEntityDescription(
    key="issur_melacha_in_effect",
    name="Issur Melacha in Effect",
    icon="mdi:power-plug-off",
)


async def async_setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    async_add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
):
    """Set up the Jewish Calendar binary sensor devices."""
    if discovery_info is None:
        return

    async_add_entities([JewishCalendarBinarySensor(hass.data[DOMAIN], BINARY_SENSORS)])
Esempio n. 26
0
    SensorEntityDescription(
        key=SENSOR_TYPE_RAINSENSOR,
        name="Rainsensor",
        icon="mdi:water",
    ),
    SensorEntityDescription(
        key=SENSOR_TYPE_RAINDELAY,
        name="Raindelay",
        icon="mdi:water-off",
    ),
)

BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key=SENSOR_TYPE_RAINSENSOR,
        name="Rainsensor",
        icon="mdi:water",
    ),
    BinarySensorEntityDescription(
        key=SENSOR_TYPE_RAINDELAY,
        name="Raindelay",
        icon="mdi:water-off",
    ),
)

TRIGGER_TIME_SCHEMA = vol.All(cv.time_period, cv.positive_timedelta, lambda td:
                              (td.total_seconds() // 60))

ZONE_SCHEMA = vol.Schema({
    vol.Optional(CONF_FRIENDLY_NAME): cv.string,
    vol.Optional(CONF_TRIGGER_TIME): TRIGGER_TIME_SCHEMA,
Esempio n. 27
0
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant

from .const import DOMAIN
from .entity import WeatherFlowEntity
from .models import WeatherFlowEntryData

_LOGGER = logging.getLogger(__name__)

BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
    BinarySensorEntityDescription(
        key="is_freezing",
        name="Is Freezing",
        icon="mdi:snowflake-alert",
    ),
    BinarySensorEntityDescription(
        key="is_raining",
        name="Is Raining",
        icon="mdi:water-percent-alert",
    ),
    BinarySensorEntityDescription(
        key="is_lightning",
        name="Is Lightning",
        icon="mdi:flash-alert",
    ),
)

Esempio n. 28
0
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_MAC, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DATA_COORDINATOR, DOMAIN
from .coordinator import SwitchbotDataUpdateCoordinator
from .entity import SwitchbotEntity

PARALLEL_UPDATES = 1

BINARY_SENSOR_TYPES: dict[str, BinarySensorEntityDescription] = {
    "calibration": BinarySensorEntityDescription(key="calibration", ),
}


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up Switchbot curtain based on a config entry."""
    coordinator: SwitchbotDataUpdateCoordinator = hass.data[DOMAIN][
        entry.entry_id][DATA_COORDINATOR]

    if not coordinator.data[entry.unique_id].get("data"):
        return

    async_add_entities([
        SwitchBotBinarySensor(
            coordinator,
Esempio n. 29
0
                self.hass,
                f"{TRACKER_HARDWARE_STATUS_UPDATED}-{self._tracker_id}",
                self.handle_hardware_status_update,
            ))

        self.async_on_remove(
            async_dispatcher_connect(
                self.hass,
                f"{SERVER_UNAVAILABLE}-{self._user_id}",
                self.handle_server_unavailable,
            ))


SENSOR_TYPE = BinarySensorEntityDescription(
    key=ATTR_BATTERY_CHARGING,
    name="Battery Charging",
    device_class=DEVICE_CLASS_BATTERY_CHARGING,
    entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up Tractive device trackers."""
    client = hass.data[DOMAIN][entry.entry_id][CLIENT]
    trackables = hass.data[DOMAIN][entry.entry_id][TRACKABLES]

    entities = [
        TractiveBinarySensor(client.user_id, item, SENSOR_TYPE)
        for item in trackables if item.tracker_details["model_number"] in
        TRACKERS_WITH_BUILTIN_BATTERY
    ]
Esempio n. 30
0
    BinarySensorEntity,
    BinarySensorEntityDescription,
)
from homeassistant.const import CONF_MONITORED_CONDITIONS
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from . import DATA_HYDRAWISE, HydrawiseEntity

_LOGGER = logging.getLogger(__name__)

BINARY_SENSOR_STATUS = BinarySensorEntityDescription(
    key="status",
    name="Status",
    device_class=BinarySensorDeviceClass.CONNECTIVITY,
)

BINARY_SENSOR_TYPES: tuple[BinarySensorEntityDescription,
                           ...] = (BinarySensorEntityDescription(
                               key="is_watering",
                               name="Watering",
                               device_class=BinarySensorDeviceClass.MOISTURE,
                           ), )

BINARY_SENSOR_KEYS: list[str] = [
    desc.key for desc in (BINARY_SENSOR_STATUS, *BINARY_SENSOR_TYPES)
]

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({