Beispiel #1
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up LGE device humidifier based on config_entry."""
    entry_config = hass.data[DOMAIN]
    lge_devices = entry_config.get(LGE_DEVICES)
    if not lge_devices:
        return

    _LOGGER.debug("Starting LGE ThinQ humidifier setup...")
    lge_humidifier = []

    # DeHumidifier devices
    lge_humidifier.extend([
        LGEDeHumidifier(lge_device)
        for lge_device in lge_devices.get(DeviceType.DEHUMIDIFIER, [])
    ])

    async_add_entities(lge_humidifier)

    # register services
    platform = current_platform.get()
    platform.async_register_entity_service(
        SERVICE_SET_FAN_MODE,
        {vol.Required(ATTR_FAN_MODE): cv.string},
        "async_set_fan_mode",
    )
Beispiel #2
0
async def async_setup_platform(
    hass: HomeAssistant,
    _: ConfigType,
    async_add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType = None,
) -> None:
    """Create the Climate entities for CH/DHW (heat) & HVAC."""
    def entity_factory(entity_class, broker, device):
        migrate_to_ramses_rf(hass, PLATFORM, f"{device.id}")
        return entity_class(broker, device)

    if discovery_info is None:
        return

    broker = hass.data[DOMAIN][BROKER]
    new_entities = []

    if tcs := discovery_info.get("tcs"):
        new_entities.append(entity_factory(EvohomeController, broker, tcs))

        if not broker._services.get(PLATFORM):
            broker._services[PLATFORM] = True

            register_svc = current_platform.get().async_register_entity_service
            [
                register_svc(k, v, f"svc_{k}")
                for k, v in SVCS_CLIMATE_EVOHOME.items()
            ]
Beispiel #3
0
async def async_setup_platform(
    hass: HomeAssistant,
    _: ConfigType,
    async_add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType = None,
) -> None:
    """Set up the sensor entities.

    discovery_info keys:
      gateway: is the ramses_rf protocol stack (gateway/protocol/transport/serial)
      devices: heat (e.g. CTL, OTB, BDR, TRV) or hvac (e.g. FAN, CO2, SWI)
      domains: TCS, DHW and Zones
    """
    def entity_factory(broker, device, attr, *, entity_class=None, **kwargs):
        migrate_to_ramses_rf(hass, "sensor", f"{device.id}-{attr}")
        return (entity_class or RamsesSensor)(broker, device, attr, **kwargs)

    if discovery_info is None:
        return

    broker = hass.data[DOMAIN][BROKER]

    new_sensors = [
        entity_factory(broker, device, k, **v)
        for device in discovery_info.get("devices", [])
        for k, v in SENSOR_ATTRS.items() if hasattr(device, k)
    ]  # and (not device._is_faked or device["fakable"])
    new_sensors += [
        entity_factory(broker, device, f"{k}_ot", **v)
        for device in discovery_info.get("devices", [])
        for k, v in SENSOR_ATTRS_HEAT.items()
        if device._SLUG == "OTB" and hasattr(device, f"{k}_ot")
    ]
    new_sensors += [
        entity_factory(broker, domain, k, **v)
        for domain in discovery_info.get("domains", [])
        for k, v in SENSOR_ATTRS_HEAT.items()
        if k == "heat_demand" and hasattr(domain, k)
    ]

    async_add_entities(new_sensors)

    if not broker._services.get(PLATFORM) and new_sensors:
        broker._services[PLATFORM] = True

        register_svc = current_platform.get().async_register_entity_service
        [register_svc(k, v, f"svc_{k}") for k, v in SVCS_SENSOR.items()]
Beispiel #4
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None) -> None:
    """Setup binary_sensor platform."""
    # pylint: disable=unused-argument

    coordinator: IUCoordinator = hass.data[DOMAIN][COORDINATOR]
    entities = []
    for controller in coordinator.controllers:
        entities.append(IUMasterEntity(coordinator, controller, None))
        for zone in controller.zones:
            entities.append(IUZoneEntity(coordinator, controller, zone))
    async_add_entities(entities)

    platform = current_platform.get()
    register_platform_services(platform)

    return
Beispiel #5
0
async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: Callable[[Iterable[Entity]], None],
) -> None:
    """Set up Verisure sensors based on a config entry."""
    coordinator: VerisureDataUpdateCoordinator = hass.data[DOMAIN][
        entry.entry_id]

    platform = current_platform.get()
    platform.async_register_entity_service(
        SERVICE_CAPTURE_SMARTCAM,
        {},
        VerisureSmartcam.capture_smartcam.__name__,
    )

    assert hass.config.config_dir
    async_add_entities(
        VerisureSmartcam(coordinator, serial_number, hass.config.config_dir)
        for serial_number in coordinator.data["cameras"])
Beispiel #6
0
async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: Callable[[Iterable[Entity]], None],
) -> None:
    """Set up Verisure alarm control panel from a config entry."""
    coordinator: VerisureDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]

    platform = current_platform.get()
    platform.async_register_entity_service(
        SERVICE_DISABLE_AUTOLOCK,
        {},
        VerisureDoorlock.disable_autolock.__name__,
    )
    platform.async_register_entity_service(
        SERVICE_ENABLE_AUTOLOCK,
        {},
        VerisureDoorlock.enable_autolock.__name__,
    )

    async_add_entities(
        VerisureDoorlock(coordinator, serial_number)
        for serial_number in coordinator.data["locks"]
    )
Beispiel #7
0
    # File "/config/custom_components/ramses_cc/binary_sensor.py", line 68, in <listcomp>
    #     if getattr(tcs, "tcs") is tcs
    # AttributeError: 'NoneType' object has no attribute 'tcs'
    new_sensors += [
        entity_factory(broker, dev, k, **v)
        for dev in discovery_info.get("domains", [])  # not "devices"
        for k, v in BINARY_SENSOR_ATTRS["systems"].items()
        if dev and getattr(dev, "tcs") is dev  # HACK
    ]  # 01:xxxxxx - active_fault, schema

    async_add_entities(new_sensors)

    if not broker._services.get(PLATFORM) and new_sensors:
        broker._services[PLATFORM] = True

        register_svc = current_platform.get().async_register_entity_service
        [register_svc(k, v, f"svc_{k}") for k, v in SVCS_BINARY_SENSOR.items()]


class RamsesBinarySensor(RamsesDeviceBase, BinarySensorEntity):
    """Representation of a generic binary sensor."""

    #

    def __init__(
        self,
        broker,
        device,
        state_attr,
        attr_name=None,
        device_id=None,