Add switch setup type hints [s-z] (#63305)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-03 16:44:20 +01:00 committed by GitHub
parent e5dcc5694a
commit f456f68dff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 200 additions and 25 deletions

View File

@ -1,9 +1,13 @@
"""Support for Satel Integra modifiable outputs represented as switches.""" """Support for Satel Integra modifiable outputs represented as switches."""
from __future__ import annotations
import logging import logging
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ( from . import (
CONF_DEVICE_CODE, CONF_DEVICE_CODE,
@ -18,7 +22,12 @@ _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ["satel_integra"] DEPENDENCIES = ["satel_integra"]
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Satel Integra switch devices.""" """Set up the Satel Integra switch devices."""
if not discovery_info: if not discovery_info:
return return

View File

@ -4,6 +4,9 @@ import logging
from screenlogicpy.const import DATA as SL_DATA, GENERIC_CIRCUIT_NAMES from screenlogicpy.const import DATA as SL_DATA, GENERIC_CIRCUIT_NAMES
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import ScreenLogicCircuitEntity from . import ScreenLogicCircuitEntity
from .const import DOMAIN, LIGHT_CIRCUIT_FUNCTIONS from .const import DOMAIN, LIGHT_CIRCUIT_FUNCTIONS
@ -11,7 +14,11 @@ from .const import DOMAIN, LIGHT_CIRCUIT_FUNCTIONS
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up entry.""" """Set up entry."""
coordinator = hass.data[DOMAIN][config_entry.entry_id] coordinator = hass.data[DOMAIN][config_entry.entry_id]
async_add_entities( async_add_entities(

View File

@ -1,4 +1,6 @@
"""Support for SCSGate switches.""" """Support for SCSGate switches."""
from __future__ import annotations
import logging import logging
from scsgate.messages import ScenarioTriggeredMessage, StateMessage from scsgate.messages import ScenarioTriggeredMessage, StateMessage
@ -7,7 +9,10 @@ import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import CONF_SCS_ID, DOMAIN, SCSGATE_SCHEMA from . import CONF_SCS_ID, DOMAIN, SCSGATE_SCHEMA
@ -21,7 +26,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the SCSGate switches.""" """Set up the SCSGate switches."""
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
scsgate = hass.data[DOMAIN] scsgate = hass.data[DOMAIN]

View File

@ -1,6 +1,9 @@
"""Support for interacting with Smappee Comport Plugs, Switches and Output Modules.""" """Support for interacting with Smappee Comport Plugs, Switches and Output Modules."""
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN from .const import DOMAIN
@ -8,7 +11,11 @@ SWITCH_PREFIX = "Switch"
ICON = "mdi:toggle-switch" ICON = "mdi:toggle-switch"
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Smappee Comfort Plugs.""" """Set up the Smappee Comfort Plugs."""
smappee_base = hass.data[DOMAIN][config_entry.entry_id] smappee_base = hass.data[DOMAIN][config_entry.entry_id]

View File

@ -6,12 +6,19 @@ from collections.abc import Sequence
from pysmartthings import Capability from pysmartthings import Capability
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import SmartThingsEntity from . import SmartThingsEntity
from .const import DATA_BROKERS, DOMAIN from .const import DATA_BROKERS, DOMAIN
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add switches for a config entry.""" """Add switches for a config entry."""
broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id] broker = hass.data[DOMAIN][DATA_BROKERS][config_entry.entry_id]
async_add_entities( async_add_entities(

View File

@ -3,13 +3,18 @@ import async_timeout
from smarttub import SpaPump from smarttub import SpaPump
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import API_TIMEOUT, ATTR_PUMPS, DOMAIN, SMARTTUB_CONTROLLER from .const import API_TIMEOUT, ATTR_PUMPS, DOMAIN, SMARTTUB_CONTROLLER
from .entity import SmartTubEntity from .entity import SmartTubEntity
from .helpers import get_spa_name from .helpers import get_spa_name
async def async_setup_entry(hass, entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up switch entities for the pumps on the tub.""" """Set up switch entities for the pumps on the tub."""
controller = hass.data[DOMAIN][entry.entry_id][SMARTTUB_CONTROLLER] controller = hass.data[DOMAIN][entry.entry_id][SMARTTUB_CONTROLLER]

View File

@ -1,4 +1,6 @@
"""Support for SNMP enabled switch.""" """Support for SNMP enabled switch."""
from __future__ import annotations
import logging import logging
import pysnmp.hlapi.asyncio as hlapi import pysnmp.hlapi.asyncio as hlapi
@ -38,7 +40,10 @@ from homeassistant.const import (
CONF_PORT, CONF_PORT,
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import ( from .const import (
CONF_AUTH_KEY, CONF_AUTH_KEY,
@ -114,7 +119,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the SNMP switch.""" """Set up the SNMP switch."""
name = config.get(CONF_NAME) name = config.get(CONF_NAME)
host = config.get(CONF_HOST) host = config.get(CONF_HOST)

View File

@ -3,12 +3,19 @@ from pymfy.api.devices.camera_protect import CameraProtect
from pymfy.api.devices.category import Category from pymfy.api.devices.category import Category
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import COORDINATOR, DOMAIN from .const import COORDINATOR, DOMAIN
from .entity import SomfyEntity from .entity import SomfyEntity
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Somfy switch platform.""" """Set up the Somfy switch platform."""
domain_data = hass.data[DOMAIN] domain_data = hass.data[DOMAIN]
coordinator = domain_data[COORDINATOR] coordinator = domain_data[COORDINATOR]

View File

@ -1,11 +1,16 @@
"""Support for Spider switches.""" """Support for Spider switches."""
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN from .const import DOMAIN
async def async_setup_entry(hass, config, async_add_entities): async def async_setup_entry(
hass: HomeAssistant, config: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Initialize a Spider Power Plug.""" """Initialize a Spider Power Plug."""
api = hass.data[DOMAIN][config.entry_id] api = hass.data[DOMAIN][config.entry_id]
async_add_entities( async_add_entities(

View File

@ -4,6 +4,9 @@ from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription 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 .account import StarlineAccount, StarlineDevice from .account import StarlineAccount, StarlineDevice
from .const import DOMAIN from .const import DOMAIN
@ -54,7 +57,9 @@ SWITCH_TYPES: tuple[StarlineSwitchEntityDescription, ...] = (
) )
async def async_setup_entry(hass, entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the StarLine switch.""" """Set up the StarLine switch."""
account: StarlineAccount = hass.data[DOMAIN][entry.entry_id] account: StarlineAccount = hass.data[DOMAIN][entry.entry_id]
entities = [ entities = [

View File

@ -1,4 +1,6 @@
"""Support for Switchmate.""" """Support for Switchmate."""
from __future__ import annotations
from datetime import timedelta from datetime import timedelta
# pylint: disable=import-error # pylint: disable=import-error
@ -7,7 +9,10 @@ import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
from homeassistant.const import CONF_MAC, CONF_NAME from homeassistant.const import CONF_MAC, CONF_NAME
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
CONF_FLIP_ON_OFF = "flip_on_off" CONF_FLIP_ON_OFF = "flip_on_off"
DEFAULT_NAME = "Switchmate" DEFAULT_NAME = "Switchmate"
@ -23,7 +28,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
def setup_platform(hass, config, add_entities, discovery_info=None) -> None: def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Perform the setup for Switchmate devices.""" """Perform the setup for Switchmate devices."""
name = config.get(CONF_NAME) name = config.get(CONF_NAME)
mac_addr = config[CONF_MAC] mac_addr = config[CONF_MAC]

View File

@ -1,12 +1,19 @@
"""Support for Tellstick switches using Tellstick Net.""" """Support for Tellstick switches using Tellstick Net."""
from homeassistant.components import switch, tellduslive from homeassistant.components import switch, tellduslive
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .entry import TelldusLiveEntity from .entry import TelldusLiveEntity
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up tellduslive sensors dynamically.""" """Set up tellduslive sensors dynamically."""
async def async_discover_switch(device_id): async def async_discover_switch(device_id):

View File

@ -1,5 +1,10 @@
"""Support for Tellstick switches.""" """Support for Tellstick switches."""
from __future__ import annotations
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ( from . import (
ATTR_DISCOVER_CONFIG, ATTR_DISCOVER_CONFIG,
@ -10,7 +15,12 @@ from . import (
) )
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up Tellstick switches.""" """Set up Tellstick switches."""
if discovery_info is None or discovery_info[ATTR_DISCOVER_DEVICES] is None: if discovery_info is None or discovery_info[ATTR_DISCOVER_DEVICES] is None:
return return

View File

@ -1,4 +1,6 @@
"""Support for switch controlled using a telnet connection.""" """Support for switch controlled using a telnet connection."""
from __future__ import annotations
from datetime import timedelta from datetime import timedelta
import logging import logging
import telnetlib import telnetlib
@ -21,7 +23,10 @@ from homeassistant.const import (
CONF_TIMEOUT, CONF_TIMEOUT,
CONF_VALUE_TEMPLATE, CONF_VALUE_TEMPLATE,
) )
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -48,7 +53,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
SCAN_INTERVAL = timedelta(seconds=10) SCAN_INTERVAL = timedelta(seconds=10)
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Find and return switches controlled by telnet commands.""" """Find and return switches controlled by telnet commands."""
devices = config.get(CONF_SWITCHES, {}) devices = config.get(CONF_SWITCHES, {})
switches = [] switches = []

View File

@ -14,7 +14,10 @@ from homeassistant.components.switch import (
SwitchEntityDescription, SwitchEntityDescription,
) )
from homeassistant.const import CONF_HOST, STATE_OFF, STATE_ON from homeassistant.const import CONF_HOST, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10) MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100) MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
@ -40,7 +43,12 @@ SWITCH_TYPES: tuple[SwitchEntityDescription, ...] = (
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string}) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_HOST): cv.string})
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the ThinkingCleaner platform.""" """Set up the ThinkingCleaner platform."""
if host := config.get(CONF_HOST): if host := config.get(CONF_HOST):
devices = [ThinkingCleaner(host, "unknown")] devices = [ThinkingCleaner(host, "unknown")]

View File

@ -1,17 +1,23 @@
"""Support for setting the Transmission BitTorrent client Turtle Mode.""" """Support for setting the Transmission BitTorrent client Turtle Mode."""
import logging import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME, STATE_OFF, STATE_ON from homeassistant.const import CONF_NAME, STATE_OFF, STATE_ON
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN, SWITCH_TYPES from .const import DOMAIN, SWITCH_TYPES
_LOGGING = logging.getLogger(__name__) _LOGGING = logging.getLogger(__name__)
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the Transmission switch.""" """Set up the Transmission switch."""
tm_client = hass.data[DOMAIN][config_entry.entry_id] tm_client = hass.data[DOMAIN][config_entry.entry_id]

View File

@ -1,10 +1,20 @@
"""Support for Volvo heater.""" """Support for Volvo heater."""
from __future__ import annotations
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import DATA_KEY, VolvoEntity from . import DATA_KEY, VolvoEntity
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up a Volvo switch.""" """Set up a Volvo switch."""
if discovery_info is None: if discovery_info is None:
return return

View File

@ -1,7 +1,12 @@
"""Support for XBee Zigbee switches.""" """Support for XBee Zigbee switches."""
from __future__ import annotations
import voluptuous as vol import voluptuous as vol
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import PLATFORM_SCHEMA, XBeeDigitalOut, XBeeDigitalOutConfig from . import PLATFORM_SCHEMA, XBeeDigitalOut, XBeeDigitalOutConfig
from .const import CONF_ON_STATE, DOMAIN, STATES from .const import CONF_ON_STATE, DOMAIN, STATES
@ -9,7 +14,12 @@ from .const import CONF_ON_STATE, DOMAIN, STATES
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_ON_STATE): vol.In(STATES)}) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Optional(CONF_ON_STATE): vol.In(STATES)})
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the XBee Zigbee switch platform.""" """Set up the XBee Zigbee switch platform."""
zigbee_device = hass.data[DOMAIN] zigbee_device = hass.data[DOMAIN]
add_entities([XBeeSwitch(XBeeDigitalOutConfig(config), zigbee_device)]) add_entities([XBeeSwitch(XBeeDigitalOutConfig(config), zigbee_device)])

View File

@ -2,6 +2,9 @@
import logging import logging
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import XiaomiDevice from . import XiaomiDevice
from .const import DOMAIN, GATEWAYS_KEY from .const import DOMAIN, GATEWAYS_KEY
@ -21,7 +24,11 @@ ENERGY_CONSUMED = "energy_consumed"
IN_USE = "inuse" IN_USE = "inuse"
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Perform the setup for Xiaomi devices.""" """Perform the setup for Xiaomi devices."""
entities = [] entities = []
gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id] gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id]

View File

@ -1,13 +1,22 @@
"""Support for XS1 switches.""" """Support for XS1 switches."""
from __future__ import annotations
from xs1_api_client.api_constants import ActuatorType from xs1_api_client.api_constants import ActuatorType
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import ToggleEntity from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, XS1DeviceEntity from . import ACTUATORS, DOMAIN as COMPONENT_DOMAIN, XS1DeviceEntity
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the XS1 switch platform.""" """Set up the XS1 switch platform."""
actuators = hass.data[COMPONENT_DOMAIN][ACTUATORS] actuators = hass.data[COMPONENT_DOMAIN][ACTUATORS]

View File

@ -1,4 +1,6 @@
"""Support for ZoneMinder switches.""" """Support for ZoneMinder switches."""
from __future__ import annotations
import logging import logging
import voluptuous as vol import voluptuous as vol
@ -6,7 +8,10 @@ from zoneminder.monitor import MonitorState
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
from homeassistant.const import CONF_COMMAND_OFF, CONF_COMMAND_ON from homeassistant.const import CONF_COMMAND_OFF, CONF_COMMAND_ON
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv 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 ZONEMINDER_DOMAIN from . import DOMAIN as ZONEMINDER_DOMAIN
@ -20,7 +25,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
) )
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(
hass: HomeAssistant,
config: ConfigType,
add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the ZoneMinder switch platform.""" """Set up the ZoneMinder switch platform."""
on_state = MonitorState(config.get(CONF_COMMAND_ON)) on_state = MonitorState(config.get(CONF_COMMAND_ON))

View File

@ -2,13 +2,19 @@
import time import time
from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.components.switch import DOMAIN, SwitchEntity
from homeassistant.core import callback from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import ZWaveDeviceEntity, workaround from . import ZWaveDeviceEntity, workaround
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Z-Wave Switch from Config Entry.""" """Set up Z-Wave Switch from Config Entry."""
@callback @callback