Exemplo n.º 1
0
async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Add entities for passed config_entry in HA."""
    hub: DeebotHub = hass.data[DOMAIN][config_entry.entry_id]

    new_devices = []
    for vacbot in hub.vacuum_bots:
        new_devices.extend([
            DeebotSwitchEntity(
                vacbot,
                SwitchEntityDescription(
                    key="advanced_mode",
                    entity_registry_enabled_default=False,
                    entity_category=EntityCategory.CONFIG,
                    icon="mdi:tune",
                ),
                AdvancedModeEvent,
                SetAdvancedMode,
            ),
            DeebotSwitchEntity(
                vacbot,
                SwitchEntityDescription(
                    key="continuous_cleaning",
                    entity_registry_enabled_default=False,
                    entity_category=EntityCategory.CONFIG,
                    icon="mdi:refresh-auto",
                ),
                ContinuousCleaningEvent,
                SetContinuousCleaning,
            ),
            DeebotSwitchEntity(
                vacbot,
                SwitchEntityDescription(
                    key="carpet_auto_fan_speed_boost",
                    entity_registry_enabled_default=False,
                    entity_category=EntityCategory.CONFIG,
                    icon="mdi:fan-auto",
                ),
                CarpetAutoFanBoostEvent,
                SetCarpetAutoFanBoost,
            ),
        ])

    if new_devices:
        async_add_entities(new_devices)
Exemplo n.º 2
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up the UptimeRobot switches."""
    coordinator: UptimeRobotDataUpdateCoordinator = hass.data[DOMAIN][
        entry.entry_id]
    async_add_entities(
        UptimeRobotSwitch(
            coordinator,
            SwitchEntityDescription(
                key=str(monitor.id),
                name=f"{monitor.friendly_name} Active",
                device_class=SwitchDeviceClass.SWITCH,
            ),
            monitor=monitor,
        ) for monitor in coordinator.data)
Exemplo n.º 3
0
class NormalizeEnabledEntity(MassBaseEntity, SwitchEntity):
    """Representation of a Switch entity to set volume normalization enabled."""

    entity_description = SwitchEntityDescription(
        key="normalize_enabled",
        device_class=SwitchDeviceClass.SWITCH,
        icon="mdi:chart-bar",
        entity_category=EntityCategory.CONFIG,
        name="Volume normalization enabled",
    )

    @property
    def is_on(self) -> bool:
        """Return true if the switch is on."""
        return self.queue.settings.volume_normalization_enabled

    async def async_turn_on(self, **kwargs: Any) -> None:
        """Turn the entity on."""
        self.queue.settings.volume_normalization_enabled = True

    async def async_turn_off(self, **kwargs: Any) -> None:
        """Turn the entity on."""
        self.queue.settings.volume_normalization_enabled = False
Exemplo n.º 4
0
)

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import ENTITY_CATEGORY_CONFIG
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from . import MotionEyeEntity, get_camera_from_cameras, listen_for_new_cameras
from .const import CONF_CLIENT, CONF_COORDINATOR, DOMAIN, TYPE_MOTIONEYE_SWITCH_BASE

MOTIONEYE_SWITCHES = [
    SwitchEntityDescription(
        key=KEY_MOTION_DETECTION,
        name="Motion Detection",
        entity_registry_enabled_default=True,
        entity_category=ENTITY_CATEGORY_CONFIG,
    ),
    SwitchEntityDescription(
        key=KEY_TEXT_OVERLAY,
        name="Text Overlay",
        entity_registry_enabled_default=False,
        entity_category=ENTITY_CATEGORY_CONFIG,
    ),
    SwitchEntityDescription(
        key=KEY_VIDEO_STREAMING,
        name="Video Streaming",
        entity_registry_enabled_default=False,
        entity_category=ENTITY_CATEGORY_CONFIG,
    ),
    SwitchEntityDescription(
Exemplo n.º 5
0
ATTR_INST_CURRENT_DDT = "instantaneous_current_ddt"
ATTR_TRAVEL_COUNT = "travel_count"

SERVICE_DISABLE_AP = "disable_ap"
SERVICE_ENABLE_AP = "enable_ap"
SERVICE_PAIR_SENSOR = "pair_sensor"
SERVICE_REBOOT = "reboot"
SERVICE_RESET_VALVE_DIAGNOSTICS = "reset_valve_diagnostics"
SERVICE_UNPAIR_SENSOR = "unpair_sensor"
SERVICE_UPGRADE_FIRMWARE = "upgrade_firmware"

SWITCH_KIND_VALVE = "valve"

SWITCH_DESCRIPTION_VALVE = SwitchEntityDescription(
    key=SWITCH_KIND_VALVE,
    name="Valve Controller",
    icon="mdi:water",
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up Guardian switches based on a config entry."""
    platform = entity_platform.async_get_current_platform()

    for service_name, schema, method in (
        (SERVICE_DISABLE_AP, {}, "async_disable_ap"),
        (SERVICE_ENABLE_AP, {}, "async_enable_ap"),
        (SERVICE_PAIR_SENSOR, {
            vol.Required(CONF_UID): cv.string
        }, "async_pair_sensor"),
Exemplo n.º 6
0
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HiveEntity, refresh_system
from .const import ATTR_MODE, DOMAIN

PARALLEL_UPDATES = 0
SCAN_INTERVAL = timedelta(seconds=15)


SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="activeplug",
    ),
    SwitchEntityDescription(key="Heating_Heat_On_Demand"),
)


async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
    """Set up Hive thermostat based on a config entry."""

    hive = hass.data[DOMAIN][entry.entry_id]
    devices = hive.session.deviceList.get("switch")
    entities = []
    if devices:
        for description in SWITCH_TYPES:
Exemplo n.º 7
0
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HomeAssistantTuyaData
from .base import TuyaEntity
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode

# All descriptions can be found here. Mostly the Boolean data types in the
# default instruction set of each category end up being a Switch.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = {
    # Smart Kettle
    # https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7
    "bh": (
        SwitchEntityDescription(
            key=DPCode.START,
            name="Start",
            icon="mdi:kettle-steam",
        ),
        SwitchEntityDescription(
            key=DPCode.WARM,
            name="Heat Preservation",
            entity_category=EntityCategory.CONFIG,
        ),
    ),
    # Smart Pet Feeder
    # https://developer.tuya.com/en/docs/iot/categorycwwsq?id=Kaiuz2b6vydld
    "cwwsq": (
        SwitchEntityDescription(
            key=DPCode.SLOW_FEED,
            name="Slow Feed",
            icon="mdi:speedometer-slow",
Exemplo n.º 8
0
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import WallboxCoordinator, WallboxEntity
from .const import (
    CHARGER_DATA_KEY,
    CHARGER_PAUSE_RESUME_KEY,
    CHARGER_SERIAL_NUMBER_KEY,
    CHARGER_STATUS_DESCRIPTION_KEY,
    DOMAIN,
    ChargerStatus,
)

SWITCH_TYPES: dict[str, SwitchEntityDescription] = {
    CHARGER_PAUSE_RESUME_KEY: SwitchEntityDescription(
        key=CHARGER_PAUSE_RESUME_KEY,
        name="Pause/Resume",
    ),
}


async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
    """Create wallbox sensor entities in HASS."""
    coordinator: WallboxCoordinator = hass.data[DOMAIN][entry.entry_id]
    async_add_entities(
        [WallboxSwitch(coordinator, entry, SWITCH_TYPES[CHARGER_PAUSE_RESUME_KEY])]
    )


class WallboxSwitch(WallboxEntity, SwitchEntity):
Exemplo n.º 9
0
    SwitchEntityDescription,
)
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 .const import DOMAIN
from .coordinator import PlugwiseDataUpdateCoordinator
from .entity import PlugwiseEntity
from .util import plugwise_command

SWITCHES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="dhw_cm_switch",
        name="DHW Comfort Mode",
        icon="mdi:water-plus",
        entity_category=EntityCategory.CONFIG,
    ),
    SwitchEntityDescription(
        key="lock",
        name="Lock",
        icon="mdi:lock",
        entity_category=EntityCategory.CONFIG,
    ),
    SwitchEntityDescription(
        key="relay",
        name="Relay",
        device_class=SwitchDeviceClass.SWITCH,
    ),
)
Exemplo n.º 10
0
from aioridwell.model import EventState, RidwellPickupEvent

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import RidwellData, RidwellEntity
from .const import DOMAIN

SWITCH_TYPE_OPT_IN = "opt_in"

SWITCH_DESCRIPTION = SwitchEntityDescription(
    key=SWITCH_TYPE_OPT_IN,
    name="Opt-In to Next Pickup",
    icon="mdi:calendar-check",
)


async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
    """Set up Ridwell sensors based on a config entry."""
    data: RidwellData = hass.data[DOMAIN][entry.entry_id]

    async_add_entities(
        [
            RidwellSwitch(data.coordinator, account, SWITCH_DESCRIPTION)
            for account in data.accounts.values()
        ]
Exemplo n.º 11
0
import voluptuous as vol

from homeassistant.components.switch import (
    PLATFORM_SCHEMA,
    SwitchEntity,
    SwitchEntityDescription,
)
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS
import homeassistant.helpers.config_validation as cv

from . import DEFAULT_ENTITY_NAMESPACE, DOMAIN as SKYBELL_DOMAIN, SkybellDevice

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="do_not_disturb",
        name="Do Not Disturb",
    ),
    SwitchEntityDescription(
        key="motion_sensor",
        name="Motion Sensor",
    ),
)
MONITORED_CONDITIONS: list[str] = [desc.key for desc in SWITCH_TYPES]

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_ENTITY_NAMESPACE, default=DEFAULT_ENTITY_NAMESPACE):
    cv.string,
    vol.Required(CONF_MONITORED_CONDITIONS, default=[]):
    vol.All(cv.ensure_list, [vol.In(MONITORED_CONDITIONS)]),
})
Exemplo n.º 12
0
    SwitchDeviceClass,
    SwitchEntity,
    SwitchEntityDescription,
)
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect

from . import ZWaveMeEntity
from .const import DOMAIN, ZWaveMePlatform

_LOGGER = logging.getLogger(__name__)
DEVICE_NAME = ZWaveMePlatform.SWITCH

SWITCH_MAP: dict[str, SwitchEntityDescription] = {
    "generic": SwitchEntityDescription(
        key="generic",
        device_class=SwitchDeviceClass.SWITCH,
    )
}


async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up the switch platform."""

    @callback
    def add_new_device(new_device):
        controller = hass.data[DOMAIN][config_entry.entry_id]
        switch = ZWaveMeSwitch(controller, new_device, SWITCH_MAP["generic"])

        async_add_entities(
            [
                switch,
Exemplo n.º 13
0
    def process_entities_callback(hass, config_entry):
        data = hass.data[DOMAIN][config_entry.entry_id]
        coordinator = data[COORDINATOR]
        state = coordinator.data

        entities = []

        # filter rules
        if "filter" in state["config"].keys():
            rules = dict_get(state, "config.filter.rule")
            if isinstance(rules, list):
                for rule in rules:
                    icon = "mdi:security-network"
                    # likely only want very specific rules to manipulate from actions
                    enabled_default = False
                    # entity_category = ENTITY_CATEGORY_CONFIG
                    device_class = DEVICE_CLASS_SWITCH

                    if "tracker" not in rule.keys():
                        continue

                    # do NOT add rules that are NAT rules
                    if "associated-rule-id" in rule.keys():
                        continue

                    # not possible to disable these rules
                    if rule["descr"] == "Anti-Lockout Rule":
                        continue

                    tracker = rule["tracker"]
                    if tracker is None:
                        continue

                    # we use tracker as the unique id
                    if len(tracker) < 1:
                        continue

                    entity = PfSenseFilterSwitch(
                        config_entry,
                        coordinator,
                        SwitchEntityDescription(
                            key="filter.{}".format(tracker),
                            name="Filter Rule {} ({})".format(
                                tracker, rule["descr"]),
                            icon=icon,
                            # entity_category=entity_category,
                            device_class=device_class,
                            entity_registry_enabled_default=enabled_default,
                        ),
                    )
                    entities.append(entity)

        # nat port forward rules
        if "nat" in state["config"].keys():
            rules = dict_get(state, "config.nat.rule")
            if isinstance(rules, list):
                for rule in rules:
                    icon = "mdi:network"
                    # likely only want very specific rules to manipulate from actions
                    enabled_default = False
                    # entity_category = ENTITY_CATEGORY_CONFIG
                    device_class = DEVICE_CLASS_SWITCH
                    tracker = dict_get(rule, "created.time")
                    if tracker is None:
                        continue

                    # we use tracker as the unique id
                    if len(tracker) < 1:
                        continue

                    entity = PfSenseNatSwitch(
                        config_entry,
                        coordinator,
                        SwitchEntityDescription(
                            key="nat_port_forward.{}".format(tracker),
                            name="NAT Port Forward Rule {} ({})".format(
                                tracker, rule["descr"]),
                            icon=icon,
                            # entity_category=entity_category,
                            device_class=device_class,
                            entity_registry_enabled_default=enabled_default,
                        ),
                    )
                    entities.append(entity)

        # nat outbound rules
        if "nat" in state["config"].keys():
            # to actually be applicable mode must by "hybrid" or "advanced"
            rules = dict_get(state, "config.nat.outbound.rule")
            if isinstance(rules, list):
                for rule in rules:
                    icon = "mdi:network"
                    # likely only want very specific rules to manipulate from actions
                    enabled_default = False
                    # entity_category = ENTITY_CATEGORY_CONFIG
                    device_class = DEVICE_CLASS_SWITCH
                    tracker = dict_get(rule, "created.time")
                    if tracker is None:
                        continue

                    if "Auto created rule" in rule["descr"]:
                        continue

                    # we use tracker as the unique id
                    if len(tracker) < 1:
                        continue

                    entity = PfSenseNatSwitch(
                        config_entry,
                        coordinator,
                        SwitchEntityDescription(
                            key="nat_outbound.{}".format(tracker),
                            name="NAT Outbound Rule {} ({})".format(
                                tracker, rule["descr"]),
                            icon=icon,
                            # entity_category=entity_category,
                            device_class=device_class,
                            entity_registry_enabled_default=enabled_default,
                        ),
                    )
                    entities.append(entity)

        # services
        for service in state["services"]:
            for property in ["status"]:
                icon = "mdi:application-cog-outline"
                # likely only want very specific services to manipulate from actions
                enabled_default = False
                # entity_category = ENTITY_CATEGORY_CONFIG
                device_class = DEVICE_CLASS_SWITCH

                entity = PfSenseServiceSwitch(
                    config_entry,
                    coordinator,
                    SwitchEntityDescription(
                        key="service.{}.{}".format(service["name"], property),
                        name="Service {} {}".format(service["name"], property),
                        icon=icon,
                        # entity_category=entity_category,
                        device_class=device_class,
                        entity_registry_enabled_default=enabled_default,
                    ),
                )
                entities.append(entity)
        return entities
Exemplo n.º 14
0
from homeassistant.components.hassio import (async_start_addon,
                                             async_stop_addon)
from homeassistant.components.hassio.const import DATA_KEY_ADDONS
from homeassistant.components.hassio.entity import HassioAddonEntity
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_STATE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import ADDONS_COORDINATOR

STATE_STARTED = "started"

SWITCH_DESCRIPTION_ADDON_STATE = SwitchEntityDescription(
    key=ATTR_STATE,
    name="State",
)


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Switch set up for Hass.io config entry."""
    coordinator = hass.data[ADDONS_COORDINATOR]

    entities = [
        HassioInfoAddonSwitch(coordinator, SWITCH_DESCRIPTION_ADDON_STATE,
                              addon)
        for addon in coordinator.data["addons"].values()
Exemplo n.º 15
0
"""Switch support for the Skybell HD Doorbell."""
from __future__ import annotations

from typing import Any, cast

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN
from .entity import SkybellEntity

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="do_not_disturb",
        name="Do not disturb",
    ),
    SwitchEntityDescription(
        key="do_not_ring",
        name="Do not ring",
    ),
    SwitchEntityDescription(
        key="motion_sensor",
        name="Motion sensor",
    ),
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up the SkyBell switch."""
Exemplo n.º 16
0
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HomeAssistantTuyaData
from .base import TuyaEntity
from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode

# All descriptions can be found here. Mostly the Boolean data types in the
# default instruction set of each category end up being a Switch.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = {
    # Smart Kettle
    # https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7
    "bh": (
        SwitchEntityDescription(
            key=DPCode.START,
            name="Start",
            icon="mdi:kettle-steam",
        ),
        SwitchEntityDescription(
            key=DPCode.WARM,
            name="Heat Preservation",
            entity_category=EntityCategory.CONFIG,
        ),
    ),
    # Pet Water Feeder
    # https://developer.tuya.com/en/docs/iot/f?id=K9gf46aewxem5
    "cwysj": (
        SwitchEntityDescription(
            key=DPCode.FILTER_RESET,
            name="Filter reset",
            icon="mdi:filter",
Exemplo n.º 17
0
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .const import DOMAIN, KEY_COORDINATOR, KEY_ROUTER
from .router import NetgearDeviceEntity, NetgearRouter

_LOGGER = logging.getLogger(__name__)

SWITCH_TYPES = [
    SwitchEntityDescription(
        key="allow_or_block",
        name="Allowed on network",
        icon="mdi:block-helper",
        entity_category=EntityCategory.CONFIG,
    )
]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up switches for Netgear component."""
    router = hass.data[DOMAIN][entry.entry_id][KEY_ROUTER]
    coordinator = hass.data[DOMAIN][entry.entry_id][KEY_COORDINATOR]
    tracked = set()

    @callback
    def new_device_callback() -> None:
        """Add new devices if needed."""
Exemplo n.º 18
0
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.const import CONF_NAME, CONF_SWITCHES
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType

from .const import DATA_AMCREST, DEVICES

if TYPE_CHECKING:
    from . import AmcrestDevice

PRIVACY_MODE_KEY = "privacy_mode"

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (SwitchEntityDescription(
    key=PRIVACY_MODE_KEY,
    name="Privacy Mode",
    icon="mdi:eye-off",
), )

SWITCH_KEYS: list[str] = [desc.key for desc in SWITCH_TYPES]


async def async_setup_platform(
    hass: HomeAssistant,
    config: ConfigType,
    async_add_entities: AddEntitiesCallback,
    discovery_info: DiscoveryInfoType | None = None,
) -> None:
    """Set up amcrest platform switches."""
    if discovery_info is None:
        return
Exemplo n.º 19
0
import homeassistant.helpers.config_validation as cv

from . import (
    ALLOWED_WATERING_TIME,
    CONF_WATERING_TIME,
    DATA_HYDRAWISE,
    DEFAULT_WATERING_TIME,
    HydrawiseEntity,
)

_LOGGER = logging.getLogger(__name__)

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="auto_watering",
        name="Automatic Watering",
        device_class=SwitchDeviceClass.SWITCH,
    ),
    SwitchEntityDescription(
        key="manual_watering",
        name="Manual Watering",
        device_class=SwitchDeviceClass.SWITCH,
    ),
)

SWITCH_KEYS: list[str] = [desc.key for desc in SWITCH_TYPES]

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Optional(CONF_MONITORED_CONDITIONS, default=SWITCH_KEYS): vol.All(
            cv.ensure_list, [vol.In(SWITCH_KEYS)]
Exemplo n.º 20
0
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
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 . import HiveEntity, refresh_system
from .const import ATTR_MODE, DOMAIN

PARALLEL_UPDATES = 0
SCAN_INTERVAL = timedelta(seconds=15)


SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="activeplug",
    ),
    SwitchEntityDescription(
        key="Heating_Heat_On_Demand",
        entity_category=EntityCategory.CONFIG,
    ),
)


async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
    """Set up Hive thermostat based on a config entry."""

    hive = hass.data[DOMAIN][entry.entry_id]
    devices = hive.session.deviceList.get("switch")
Exemplo n.º 21
0
from typing import Any, cast

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

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

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="v12PortStatus",
        name="12V Port Status",
    ),
    SwitchEntityDescription(
        key="usbPortStatus",
        name="USB Port Status",
    ),
    SwitchEntityDescription(
        key="acPortStatus",
        name="AC Port Status",
    ),
)


async def async_setup_entry(
    hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
Exemplo n.º 22
0
from homeassistant.components.switch import (
    PLATFORM_SCHEMA,
    SwitchEntity,
    SwitchEntityDescription,
)
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 DOMAIN as WIRELESSTAG_DOMAIN, WirelessTagBaseSensor

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="temperature",
        name="Arm Temperature",
    ),
    SwitchEntityDescription(
        key="humidity",
        name="Arm Humidity",
    ),
    SwitchEntityDescription(
        key="motion",
        name="Arm Motion",
    ),
    SwitchEntityDescription(
        key="light",
        name="Arm Light",
    ),
    SwitchEntityDescription(
        key="moisture",
Exemplo n.º 23
0
    PLATFORM_SCHEMA,
    SwitchEntity,
    SwitchEntityDescription,
)
from homeassistant.const import CONF_HOST, STATE_OFF, STATE_ON
import homeassistant.helpers.config_validation as cv

MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)

MIN_TIME_TO_WAIT = timedelta(seconds=5)
MIN_TIME_TO_LOCK_UPDATE = 5

SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
    SwitchEntityDescription(
        key="clean",
        name="Clean",
    ),
    SwitchEntityDescription(
        key="dock",
        name="Dock",
    ),
    SwitchEntityDescription(
        key="find",
        name="Find",
    ),
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string})


def setup_platform(hass, config, add_entities, discovery_info=None):
Exemplo n.º 24
0
"""Support for Steamist switches."""
from __future__ import annotations

from typing import Any

from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN
from .coordinator import SteamistDataUpdateCoordinator
from .entity import SteamistEntity

ACTIVE_SWITCH = SwitchEntityDescription(key="active",
                                        icon="mdi:pot-steam",
                                        name="Steam Active")


async def async_setup_entry(
    hass: HomeAssistant,
    config_entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up sensors."""
    coordinator: SteamistDataUpdateCoordinator = hass.data[DOMAIN][
        config_entry.entry_id]
    async_add_entities(
        [SteamistSwitchEntity(coordinator, config_entry, ACTIVE_SWITCH)])