コード例 #1
0
ファイル: button.py プロジェクト: VerityNH/myhome-hassio
 def __init__(self, vacuum_bot: VacuumBot, component: LifeSpan):
     entity_description = ButtonEntityDescription(
         key=f"life_span_{component.name.lower()}_reset",
         icon="mdi:air-filter" if component == LifeSpan.FILTER else "mdi:broom",
         entity_registry_enabled_default=True,  # Can be enabled as they don't poll data
         entity_category=EntityCategory.CONFIG,
     )
     super().__init__(vacuum_bot, entity_description)
     self._component = component
コード例 #2
0
 def __init__(self, client: Elgato, info: Info, mac: str | None) -> None:
     """Initialize the button entity."""
     super().__init__(client, info, mac)
     self.entity_description = ButtonEntityDescription(
         key="identify",
         name="Identify",
         icon="mdi:help",
         entity_category=EntityCategory.CONFIG,
     )
     self._attr_unique_id = f"{info.serial_number}_{self.entity_description.key}"
コード例 #3
0
 def __init__(self, elgato: Elgato, info: Info) -> None:
     """Initialize the button entity."""
     self.elgato = elgato
     self._info = info
     self.entity_description = ButtonEntityDescription(
         key="identify",
         name="Identify",
         icon="mdi:help",
         entity_category=EntityCategory.CONFIG,
     )
     self._attr_unique_id = f"{info.serial_number}_{self.entity_description.key}"
コード例 #4
0
from homeassistant.helpers.entity import EntityCategory
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.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = {
    # Robot Vacuum
    # https://developer.tuya.com/en/docs/iot/fsd?id=K9gf487ck1tlo
    "sd": (
        ButtonEntityDescription(
            key=DPCode.RESET_DUSTER_CLOTH,
            name="Reset Duster Cloth",
            icon="mdi:restart",
            entity_category=EntityCategory.CONFIG,
        ),
        ButtonEntityDescription(
            key=DPCode.RESET_EDGE_BRUSH,
            name="Reset Edge Brush",
            icon="mdi:restart",
            entity_category=EntityCategory.CONFIG,
        ),
        ButtonEntityDescription(
            key=DPCode.RESET_FILTER,
            name="Reset Filter",
            icon="mdi:air-filter",
            entity_category=EntityCategory.CONFIG,
        ),
        ButtonEntityDescription(
コード例 #5
0
ファイル: button.py プロジェクト: 2Fake/core
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 homeassistant.helpers.update_coordinator import CoordinatorEntity

from . import NAMDataUpdateCoordinator
from .const import DEFAULT_NAME, DOMAIN

PARALLEL_UPDATES = 1

_LOGGER = logging.getLogger(__name__)

RESTART_BUTTON: ButtonEntityDescription = ButtonEntityDescription(
    key="restart",
    name=f"{DEFAULT_NAME} Restart",
    device_class=ButtonDeviceClass.RESTART,
    entity_category=EntityCategory.CONFIG,
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Add a Nettigo Air Monitor entities from a config_entry."""
    coordinator: NAMDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]

    buttons: list[NAMButton] = []
    buttons.append(NAMButton(coordinator, RESTART_BUTTON))

    async_add_entities(buttons, False)

コード例 #6
0
from homeassistant.helpers.entity import EntityCategory
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.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = {
    # Robot Vacuum
    # https://developer.tuya.com/en/docs/iot/fsd?id=K9gf487ck1tlo
    "sd": (
        ButtonEntityDescription(
            key=DPCode.RESET_DUSTER_CLOTH,
            name="Reset duster cloth",
            icon="mdi:restart",
            entity_category=EntityCategory.CONFIG,
        ),
        ButtonEntityDescription(
            key=DPCode.RESET_EDGE_BRUSH,
            name="Reset edge brush",
            icon="mdi:restart",
            entity_category=EntityCategory.CONFIG,
        ),
        ButtonEntityDescription(
            key=DPCode.RESET_FILTER,
            name="Reset filter",
            icon="mdi:air-filter",
            entity_category=EntityCategory.CONFIG,
        ),
        ButtonEntityDescription(
コード例 #7
0
ファイル: button.py プロジェクト: jbouwh/core
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN
from .coordinator import SensiboDataUpdateCoordinator
from .entity import SensiboDeviceBaseEntity

PARALLEL_UPDATES = 0

DEVICE_BUTTON_TYPES: ButtonEntityDescription = ButtonEntityDescription(
    key="reset_filter",
    name="Reset filter",
    icon="mdi:air-filter",
    entity_category=EntityCategory.CONFIG,
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Set up Sensibo binary sensor platform."""

    coordinator: SensiboDataUpdateCoordinator = hass.data[DOMAIN][
        entry.entry_id]

    entities: list[SensiboDeviceButton] = []

    entities.extend(
        SensiboDeviceButton(coordinator, device_id, DEVICE_BUTTON_TYPES)
コード例 #8
0
    ButtonEntityDescription,
)
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 .const import DOMAIN
from .coordinator import FluxLedUpdateCoordinator
from .entity import FluxBaseEntity

_RESTART_KEY = "restart"
_UNPAIR_REMOTES_KEY = "unpair_remotes"

RESTART_BUTTON_DESCRIPTION = ButtonEntityDescription(
    key=_RESTART_KEY, name="Restart", device_class=ButtonDeviceClass.RESTART
)
UNPAIR_REMOTES_DESCRIPTION = ButtonEntityDescription(
    key=_UNPAIR_REMOTES_KEY, name="Unpair Remotes", icon="mdi:remote-off"
)


async def async_setup_entry(
    hass: HomeAssistant,
    entry: config_entries.ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up Magic Home button based on a config entry."""
    coordinator: FluxLedUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
    device = coordinator.device
    entities: list[FluxButton] = [
コード例 #9
0
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
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 HomeAssistantOverkizData
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES
from .entity import OverkizDescriptiveEntity

BUTTON_DESCRIPTIONS: list[ButtonEntityDescription] = [
    # My Position (cover, light)
    ButtonEntityDescription(
        key="my",
        name="My Position",
        icon="mdi:star",
    ),
    # Identify
    ButtonEntityDescription(
        key="identify",  # startIdentify and identify are reversed... Swap this when fixed in API.
        name="Start Identify",
        icon="mdi:human-greeting-variant",
        entity_category=EntityCategory.DIAGNOSTIC,
        entity_registry_enabled_default=False,
    ),
    ButtonEntityDescription(
        key="stopIdentify",
        name="Stop Identify",
        icon="mdi:human-greeting-variant",
        entity_category=EntityCategory.DIAGNOSTIC,
コード例 #10
0
"""GoodWe PV inverter selection settings entities."""
import logging

from datetime import datetime
from goodwe import Inverter, InverterError

from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.helpers.entity import DeviceInfo, EntityCategory

from .const import DOMAIN, KEY_DEVICE_INFO, KEY_INVERTER

_LOGGER = logging.getLogger(__name__)

SYNCHRONIZE_CLOCK = ButtonEntityDescription(
    key="synchronize_clock",
    name="Synchronize inverter clock",
    icon="mdi:clock-check-outline",
    entity_category=EntityCategory.CONFIG,
)


async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up the inverter select entities from a config entry."""
    inverter = hass.data[DOMAIN][config_entry.entry_id][KEY_INVERTER]
    device_info = hass.data[DOMAIN][config_entry.entry_id][KEY_DEVICE_INFO]

    # read current time from the inverter
    try:
        await inverter.read_setting("time")
    except (InverterError, ValueError):
        # Inverter model does not support clock synchronization
        _LOGGER.debug("Could not read inverter current clock time")
コード例 #11
0
ファイル: button.py プロジェクト: jbouwh/core
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
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 homeassistant.helpers.update_coordinator import CoordinatorEntity

from . import NextDnsStatusUpdateCoordinator
from .const import ATTR_STATUS, DOMAIN

PARALLEL_UPDATES = 1

CLEAR_LOGS_BUTTON = ButtonEntityDescription(
    key="clear_logs",
    name="Clear logs",
    entity_category=EntityCategory.CONFIG,
)


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry,
                            async_add_entities: AddEntitiesCallback) -> None:
    """Add aNextDNS entities from a config_entry."""
    coordinator: NextDnsStatusUpdateCoordinator = hass.data[DOMAIN][
        entry.entry_id][ATTR_STATUS]

    buttons: list[NextDnsButton] = []
    buttons.append(NextDnsButton(coordinator, CLEAR_LOGS_BUTTON))

    async_add_entities(buttons)
コード例 #12
0
ファイル: button.py プロジェクト: jbouwh/core
    ButtonDeviceClass,
    ButtonEntity,
    ButtonEntityDescription,
)
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, IDENTIFY, RESTART
from .coordinator import LIFXUpdateCoordinator
from .entity import LIFXEntity

RESTART_BUTTON_DESCRIPTION = ButtonEntityDescription(
    key=RESTART,
    name="Restart",
    device_class=ButtonDeviceClass.RESTART,
    entity_category=EntityCategory.CONFIG,
)

IDENTIFY_BUTTON_DESCRIPTION = ButtonEntityDescription(
    key=IDENTIFY,
    name="Identify",
    entity_category=EntityCategory.CONFIG,
)


async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
コード例 #13
0
ファイル: button.py プロジェクト: jcgoette/core
from __future__ import annotations

from typing import TYPE_CHECKING, Any

from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
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 .const import COORDINATOR, DOMAIN
from .coordinator import YaleDataUpdateCoordinator
from .entity import YaleAlarmEntity

BUTTON_TYPES = (ButtonEntityDescription(key="panic",
                                        name="Panic Button",
                                        icon="mdi:alarm-light"), )


async def async_setup_entry(
    hass: HomeAssistant,
    entry: ConfigEntry,
    async_add_entities: AddEntitiesCallback,
) -> None:
    """Set up the button from a config entry."""

    coordinator: YaleDataUpdateCoordinator = hass.data[DOMAIN][
        entry.entry_id][COORDINATOR]

    async_add_entities([
        YalePanicButton(coordinator, description)
コード例 #14
0
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import HomeAssistantOverkizData
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES
from .entity import OverkizDescriptiveEntity

BUTTON_DESCRIPTIONS: list[ButtonEntityDescription] = [
    # My Position (cover, light)
    ButtonEntityDescription(
        key="my",
        name="My Position",
        icon="mdi:star",
    ),
    # Identify
    ButtonEntityDescription(
        key="identify",  # startIdentify and identify are reversed... Swap this when fixed in API.
        name="Start Identify",
        icon="mdi:human-greeting-variant",
        entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
        entity_registry_enabled_default=False,
    ),
    ButtonEntityDescription(
        key="stopIdentify",
        name="Stop Identify",
        icon="mdi:human-greeting-variant",
        entity_category=ENTITY_CATEGORY_DIAGNOSTIC,