diff --git a/homeassistant/components/abode/switch.py b/homeassistant/components/abode/switch.py index bbd90442cd9..0985ce5ce2a 100644 --- a/homeassistant/components/abode/switch.py +++ b/homeassistant/components/abode/switch.py @@ -1,7 +1,7 @@ """Support for Abode Security System switches.""" import abodepy.helpers.constants as CONST -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.helpers.dispatcher import async_dispatcher_connect from . import AbodeAutomation, AbodeDevice @@ -28,7 +28,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class AbodeSwitch(AbodeDevice, SwitchDevice): +class AbodeSwitch(AbodeDevice, SwitchEntity): """Representation of an Abode switch.""" def turn_on(self, **kwargs): @@ -45,7 +45,7 @@ class AbodeSwitch(AbodeDevice, SwitchDevice): return self._device.is_on -class AbodeAutomationSwitch(AbodeAutomation, SwitchDevice): +class AbodeAutomationSwitch(AbodeAutomation, SwitchEntity): """A switch implementation for Abode automations.""" async def async_added_to_hass(self): diff --git a/homeassistant/components/acer_projector/switch.py b/homeassistant/components/acer_projector/switch.py index 9afc9963522..f947f3fe0c0 100644 --- a/homeassistant/components/acer_projector/switch.py +++ b/homeassistant/components/acer_projector/switch.py @@ -5,7 +5,7 @@ import re import serial import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_FILENAME, CONF_NAME, @@ -69,7 +69,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([AcerSwitch(serial_port, name, timeout, write_timeout)], True) -class AcerSwitch(SwitchDevice): +class AcerSwitch(SwitchEntity): """Represents an Acer Projector as a switch.""" def __init__(self, serial_port, name, timeout, write_timeout, **kwargs): diff --git a/homeassistant/components/adguard/switch.py b/homeassistant/components/adguard/switch.py index 1ddefb3367b..78d2769ce5d 100644 --- a/homeassistant/components/adguard/switch.py +++ b/homeassistant/components/adguard/switch.py @@ -10,7 +10,7 @@ from homeassistant.components.adguard.const import ( DATA_ADGUARD_VERION, DOMAIN, ) -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.typing import HomeAssistantType @@ -45,7 +45,7 @@ async def async_setup_entry( async_add_entities(switches, True) -class AdGuardHomeSwitch(AdGuardHomeDeviceEntity, SwitchDevice): +class AdGuardHomeSwitch(AdGuardHomeDeviceEntity, SwitchEntity): """Defines a AdGuard Home switch.""" def __init__( diff --git a/homeassistant/components/ads/switch.py b/homeassistant/components/ads/switch.py index 64c797ff309..c8231d8a31d 100644 --- a/homeassistant/components/ads/switch.py +++ b/homeassistant/components/ads/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv @@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([AdsSwitch(ads_hub, name, ads_var)]) -class AdsSwitch(AdsEntity, SwitchDevice): +class AdsSwitch(AdsEntity, SwitchEntity): """Representation of an ADS switch device.""" async def async_added_to_hass(self): diff --git a/homeassistant/components/android_ip_webcam/switch.py b/homeassistant/components/android_ip_webcam/switch.py index a494e78bdc7..bdbb37e7661 100644 --- a/homeassistant/components/android_ip_webcam/switch.py +++ b/homeassistant/components/android_ip_webcam/switch.py @@ -1,5 +1,5 @@ """Support for Android IP Webcam settings.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import ( CONF_HOST, @@ -30,7 +30,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(all_switches, True) -class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchDevice): +class IPWebcamSettingsSwitch(AndroidIPCamEntity, SwitchEntity): """An abstract class for an IP Webcam setting.""" def __init__(self, name, host, ipcam, setting): diff --git a/homeassistant/components/anel_pwrctrl/switch.py b/homeassistant/components/anel_pwrctrl/switch.py index cc6011d9b65..c769f51d5b6 100644 --- a/homeassistant/components/anel_pwrctrl/switch.py +++ b/homeassistant/components/anel_pwrctrl/switch.py @@ -5,7 +5,7 @@ import logging from anel_pwrctrl import DeviceMaster import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle @@ -58,7 +58,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class PwrCtrlSwitch(SwitchDevice): +class PwrCtrlSwitch(SwitchEntity): """Representation of a PwrCtrl switch.""" def __init__(self, port, parent_device): diff --git a/homeassistant/components/aqualogic/switch.py b/homeassistant/components/aqualogic/switch.py index d949175bc6e..94822eaef18 100644 --- a/homeassistant/components/aqualogic/switch.py +++ b/homeassistant/components/aqualogic/switch.py @@ -4,7 +4,7 @@ import logging from aqualogic.core import States import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -45,7 +45,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(switches) -class AquaLogicSwitch(SwitchDevice): +class AquaLogicSwitch(SwitchEntity): """Switch implementation for the AquaLogic component.""" def __init__(self, processor, switch_type): diff --git a/homeassistant/components/arduino/switch.py b/homeassistant/components/arduino/switch.py index ea6f36ac7f5..99b73c86fdb 100644 --- a/homeassistant/components/arduino/switch.py +++ b/homeassistant/components/arduino/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv @@ -41,7 +41,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class ArduinoSwitch(SwitchDevice): +class ArduinoSwitch(SwitchEntity): """Representation of an Arduino switch.""" def __init__(self, pin, options, board): diff --git a/homeassistant/components/arest/switch.py b/homeassistant/components/arest/switch.py index 875211f5f0b..ddd6b51f76d 100644 --- a/homeassistant/components/arest/switch.py +++ b/homeassistant/components/arest/switch.py @@ -5,7 +5,7 @@ import logging import requests import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME, CONF_RESOURCE, HTTP_OK import homeassistant.helpers.config_validation as cv @@ -80,7 +80,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev) -class ArestSwitchBase(SwitchDevice): +class ArestSwitchBase(SwitchEntity): """Representation of an aREST switch.""" def __init__(self, resource, location, name): diff --git a/homeassistant/components/aten_pe/switch.py b/homeassistant/components/aten_pe/switch.py index 2ec6ec4b83d..e5970fc4d3b 100644 --- a/homeassistant/components/aten_pe/switch.py +++ b/homeassistant/components/aten_pe/switch.py @@ -8,7 +8,7 @@ import voluptuous as vol from homeassistant.components.switch import ( DEVICE_CLASS_OUTLET, PLATFORM_SCHEMA, - SwitchDevice, + SwitchEntity, ) from homeassistant.const import CONF_HOST, CONF_PORT, CONF_USERNAME from homeassistant.exceptions import PlatformNotReady @@ -64,7 +64,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(switches) -class AtenSwitch(SwitchDevice): +class AtenSwitch(SwitchEntity): """Represents an ATEN PE switch.""" def __init__(self, device, mac, outlet, name): diff --git a/homeassistant/components/axis/switch.py b/homeassistant/components/axis/switch.py index ed822543a00..be048a510ed 100644 --- a/homeassistant/components/axis/switch.py +++ b/homeassistant/components/axis/switch.py @@ -2,7 +2,7 @@ from axis.event_stream import CLASS_OUTPUT -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class AxisSwitch(AxisEventBase, SwitchDevice): +class AxisSwitch(AxisEventBase, SwitchEntity): """Representation of a Axis switch.""" @property diff --git a/homeassistant/components/broadlink/switch.py b/homeassistant/components/broadlink/switch.py index 6eed0646d76..4173fa4adc6 100644 --- a/homeassistant/components/broadlink/switch.py +++ b/homeassistant/components/broadlink/switch.py @@ -7,7 +7,7 @@ import socket import broadlink as blk import voluptuous as vol -from homeassistant.components.switch import DOMAIN, PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import DOMAIN, PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_COMMAND_OFF, CONF_COMMAND_ON, @@ -146,7 +146,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class BroadlinkRMSwitch(SwitchDevice, RestoreEntity): +class BroadlinkRMSwitch(SwitchEntity, RestoreEntity): """Representation of an Broadlink switch.""" def __init__( diff --git a/homeassistant/components/command_line/switch.py b/homeassistant/components/command_line/switch.py index f89ac6f5b92..7f62970b639 100644 --- a/homeassistant/components/command_line/switch.py +++ b/homeassistant/components/command_line/switch.py @@ -7,7 +7,7 @@ import voluptuous as vol from homeassistant.components.switch import ( ENTITY_ID_FORMAT, PLATFORM_SCHEMA, - SwitchDevice, + SwitchEntity, ) from homeassistant.const import ( CONF_COMMAND_OFF, @@ -66,7 +66,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class CommandSwitch(SwitchDevice): +class CommandSwitch(SwitchEntity): """Representation a switch that can be toggled using shell commands.""" def __init__( diff --git a/homeassistant/components/danfoss_air/switch.py b/homeassistant/components/danfoss_air/switch.py index 96e363951c8..dc4c79ed10f 100644 --- a/homeassistant/components/danfoss_air/switch.py +++ b/homeassistant/components/danfoss_air/switch.py @@ -3,7 +3,7 @@ import logging from pydanfossair.commands import ReadCommand, UpdateCommand -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN as DANFOSS_AIR_DOMAIN @@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev) -class DanfossAir(SwitchDevice): +class DanfossAir(SwitchEntity): """Representation of a Danfoss Air HRV Switch.""" def __init__(self, data, name, state_command, on_command, off_command): diff --git a/homeassistant/components/deconz/switch.py b/homeassistant/components/deconz/switch.py index 1b51256580a..d7b6b55fbb8 100644 --- a/homeassistant/components/deconz/switch.py +++ b/homeassistant/components/deconz/switch.py @@ -1,5 +1,5 @@ """Support for deCONZ switches.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -43,7 +43,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_switch(gateway.api.lights.values()) -class DeconzPowerPlug(DeconzDevice, SwitchDevice): +class DeconzPowerPlug(DeconzDevice, SwitchEntity): """Representation of a deCONZ power plug.""" @property @@ -62,7 +62,7 @@ class DeconzPowerPlug(DeconzDevice, SwitchDevice): await self._device.async_set_state(data) -class DeconzSiren(DeconzDevice, SwitchDevice): +class DeconzSiren(DeconzDevice, SwitchEntity): """Representation of a deCONZ siren.""" @property diff --git a/homeassistant/components/demo/switch.py b/homeassistant/components/demo/switch.py index 5050b2283b4..cdbeb142677 100644 --- a/homeassistant/components/demo/switch.py +++ b/homeassistant/components/demo/switch.py @@ -1,5 +1,5 @@ """Demo platform that has two fake switches.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import DEVICE_DEFAULT_NAME from . import DOMAIN @@ -27,7 +27,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): await async_setup_platform(hass, {}, async_add_entities) -class DemoSwitch(SwitchDevice): +class DemoSwitch(SwitchEntity): """Representation of a demo switch.""" def __init__(self, unique_id, name, state, icon, assumed, device_class=None): diff --git a/homeassistant/components/digital_ocean/switch.py b/homeassistant/components/digital_ocean/switch.py index 9b9b8157bce..811b844e35c 100644 --- a/homeassistant/components/digital_ocean/switch.py +++ b/homeassistant/components/digital_ocean/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ATTR_ATTRIBUTION import homeassistant.helpers.config_validation as cv @@ -50,7 +50,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class DigitalOceanSwitch(SwitchDevice): +class DigitalOceanSwitch(SwitchEntity): """Representation of a Digital Ocean droplet switch.""" def __init__(self, do, droplet_id): diff --git a/homeassistant/components/digitalloggers/switch.py b/homeassistant/components/digitalloggers/switch.py index 268ec581c00..7448b9fbcf3 100644 --- a/homeassistant/components/digitalloggers/switch.py +++ b/homeassistant/components/digitalloggers/switch.py @@ -5,7 +5,7 @@ import logging import dlipower import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -72,7 +72,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(outlets) -class DINRelay(SwitchDevice): +class DINRelay(SwitchEntity): """Representation of an individual DIN III relay port.""" def __init__(self, controller_name, parent_device, outlet): diff --git a/homeassistant/components/dlink/switch.py b/homeassistant/components/dlink/switch.py index 1cc0e16f30f..c173c879ad1 100644 --- a/homeassistant/components/dlink/switch.py +++ b/homeassistant/components/dlink/switch.py @@ -6,7 +6,7 @@ import urllib from pyW215.pyW215 import SmartPlug import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( ATTR_TEMPERATURE, CONF_HOST, @@ -56,7 +56,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([SmartPlugSwitch(hass, data, name)], True) -class SmartPlugSwitch(SwitchDevice): +class SmartPlugSwitch(SwitchEntity): """Representation of a D-Link Smart Plug switch.""" def __init__(self, hass, data, name): diff --git a/homeassistant/components/doorbird/switch.py b/homeassistant/components/doorbird/switch.py index 9f292803b8b..1e4cb81a5eb 100644 --- a/homeassistant/components/doorbird/switch.py +++ b/homeassistant/components/doorbird/switch.py @@ -2,7 +2,7 @@ import datetime import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity import homeassistant.util.dt as dt_util from .const import DOMAIN, DOOR_STATION, DOOR_STATION_INFO @@ -31,7 +31,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class DoorBirdSwitch(DoorBirdEntity, SwitchDevice): +class DoorBirdSwitch(DoorBirdEntity, SwitchEntity): """A relay in a DoorBird device.""" def __init__(self, doorstation, doorstation_info, relay): diff --git a/homeassistant/components/dynalite/switch.py b/homeassistant/components/dynalite/switch.py index 45e24d8193a..d106d976d68 100644 --- a/homeassistant/components/dynalite/switch.py +++ b/homeassistant/components/dynalite/switch.py @@ -1,7 +1,7 @@ """Support for the Dynalite channels and presets as switches.""" from typing import Callable -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -18,7 +18,7 @@ async def async_setup_entry( ) -class DynaliteSwitch(DynaliteBase, SwitchDevice): +class DynaliteSwitch(DynaliteBase, SwitchEntity): """Representation of a Dynalite Channel as a Home Assistant Switch.""" @property diff --git a/homeassistant/components/ecoal_boiler/switch.py b/homeassistant/components/ecoal_boiler/switch.py index 00bfd7f3e5b..bd3b216d705 100644 --- a/homeassistant/components/ecoal_boiler/switch.py +++ b/homeassistant/components/ecoal_boiler/switch.py @@ -2,7 +2,7 @@ import logging from typing import Optional -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import AVAILABLE_PUMPS, DATA_ECOAL_BOILER @@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches, True) -class EcoalSwitch(SwitchDevice): +class EcoalSwitch(SwitchEntity): """Representation of Ecoal switch.""" def __init__(self, ecoal_contr, name, state_attr): diff --git a/homeassistant/components/edimax/switch.py b/homeassistant/components/edimax/switch.py index e44ec23bca7..17a43f36235 100644 --- a/homeassistant/components/edimax/switch.py +++ b/homeassistant/components/edimax/switch.py @@ -4,7 +4,7 @@ import logging from pyedimax.smartplug import SmartPlug import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME import homeassistant.helpers.config_validation as cv @@ -35,7 +35,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([SmartPlugSwitch(SmartPlug(host, auth), name)], True) -class SmartPlugSwitch(SwitchDevice): +class SmartPlugSwitch(SwitchEntity): """Representation an Edimax Smart Plug switch.""" def __init__(self, smartplug, name): diff --git a/homeassistant/components/elkm1/switch.py b/homeassistant/components/elkm1/switch.py index af32e81bc4c..d9eb59737b6 100644 --- a/homeassistant/components/elkm1/switch.py +++ b/homeassistant/components/elkm1/switch.py @@ -1,5 +1,5 @@ """Support for control of ElkM1 outputs (relays).""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import ElkAttachedEntity, create_elk_entities from .const import DOMAIN @@ -14,7 +14,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class ElkOutput(ElkAttachedEntity, SwitchDevice): +class ElkOutput(ElkAttachedEntity, SwitchEntity): """Elk output as switch.""" @property diff --git a/homeassistant/components/elv/switch.py b/homeassistant/components/elv/switch.py index d867d286f50..12b21c23d1a 100644 --- a/homeassistant/components/elv/switch.py +++ b/homeassistant/components/elv/switch.py @@ -4,7 +4,7 @@ import logging import pypca from serial import SerialException -from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchDevice +from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchEntity from homeassistant.const import EVENT_HOMEASSISTANT_STOP _LOGGER = logging.getLogger(__name__) @@ -38,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): pca.start_scan() -class SmartPlugSwitch(SwitchDevice): +class SmartPlugSwitch(SwitchEntity): """Representation of a PCA Smart Plug switch.""" def __init__(self, pca, device_id): diff --git a/homeassistant/components/esphome/switch.py b/homeassistant/components/esphome/switch.py index b52d630e1b4..a3c7eeab946 100644 --- a/homeassistant/components/esphome/switch.py +++ b/homeassistant/components/esphome/switch.py @@ -4,7 +4,7 @@ from typing import Optional from aioesphomeapi import SwitchInfo, SwitchState -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType @@ -28,7 +28,7 @@ async def async_setup_entry( ) -class EsphomeSwitch(EsphomeEntity, SwitchDevice): +class EsphomeSwitch(EsphomeEntity, SwitchEntity): """A switch implementation for ESPHome.""" @property diff --git a/homeassistant/components/eufy/switch.py b/homeassistant/components/eufy/switch.py index cbc09f4101c..586965aa42b 100644 --- a/homeassistant/components/eufy/switch.py +++ b/homeassistant/components/eufy/switch.py @@ -3,7 +3,7 @@ import logging import lakeside -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity _LOGGER = logging.getLogger(__name__) @@ -15,7 +15,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([EufySwitch(discovery_info)], True) -class EufySwitch(SwitchDevice): +class EufySwitch(SwitchEntity): """Representation of a Eufy switch.""" def __init__(self, device): diff --git a/homeassistant/components/fibaro/switch.py b/homeassistant/components/fibaro/switch.py index b00e5817c9e..a38f642775f 100644 --- a/homeassistant/components/fibaro/switch.py +++ b/homeassistant/components/fibaro/switch.py @@ -1,7 +1,7 @@ """Support for Fibaro switches.""" import logging -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.util import convert from . import FIBARO_DEVICES, FibaroDevice @@ -19,7 +19,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class FibaroSwitch(FibaroDevice, SwitchDevice): +class FibaroSwitch(FibaroDevice, SwitchEntity): """Representation of a Fibaro Switch.""" def __init__(self, fibaro_device): diff --git a/homeassistant/components/flux/switch.py b/homeassistant/components/flux/switch.py index 61bdb9a2862..8a27c99c78d 100644 --- a/homeassistant/components/flux/switch.py +++ b/homeassistant/components/flux/switch.py @@ -19,7 +19,7 @@ from homeassistant.components.light import ( VALID_TRANSITION, is_on, ) -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.const import ( ATTR_ENTITY_ID, CONF_LIGHTS, @@ -168,7 +168,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= hass.services.async_register(DOMAIN, service_name, async_update) -class FluxSwitch(SwitchDevice, RestoreEntity): +class FluxSwitch(SwitchEntity, RestoreEntity): """Representation of a Flux switch.""" def __init__( diff --git a/homeassistant/components/freebox/switch.py b/homeassistant/components/freebox/switch.py index 9e1011d5d3c..7f8934d9d65 100644 --- a/homeassistant/components/freebox/switch.py +++ b/homeassistant/components/freebox/switch.py @@ -4,7 +4,7 @@ from typing import Dict from aiofreepybox.exceptions import InsufficientPermissionsError -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType @@ -22,7 +22,7 @@ async def async_setup_entry( async_add_entities([FreeboxWifiSwitch(router)], True) -class FreeboxWifiSwitch(SwitchDevice): +class FreeboxWifiSwitch(SwitchEntity): """Representation of a freebox wifi switch.""" def __init__(self, router: FreeboxRouter) -> None: diff --git a/homeassistant/components/fritzbox/switch.py b/homeassistant/components/fritzbox/switch.py index 6f98667304b..b179464182f 100644 --- a/homeassistant/components/fritzbox/switch.py +++ b/homeassistant/components/fritzbox/switch.py @@ -1,7 +1,7 @@ """Support for AVM Fritz!Box smarthome switch devices.""" import requests -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import ( ATTR_TEMPERATURE, CONF_DEVICES, @@ -37,7 +37,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities) -class FritzboxSwitch(SwitchDevice): +class FritzboxSwitch(SwitchEntity): """The switch class for Fritzbox switches.""" def __init__(self, device, fritz): diff --git a/homeassistant/components/geniushub/switch.py b/homeassistant/components/geniushub/switch.py index b73c9a89041..e73468321bd 100644 --- a/homeassistant/components/geniushub/switch.py +++ b/homeassistant/components/geniushub/switch.py @@ -1,5 +1,5 @@ """Support for Genius Hub switch/outlet devices.""" -from homeassistant.components.switch import DEVICE_CLASS_OUTLET, SwitchDevice +from homeassistant.components.switch import DEVICE_CLASS_OUTLET, SwitchEntity from homeassistant.helpers.typing import ConfigType, HomeAssistantType from . import DOMAIN, GeniusZone @@ -27,7 +27,7 @@ async def async_setup_platform( ) -class GeniusSwitch(GeniusZone, SwitchDevice): +class GeniusSwitch(GeniusZone, SwitchEntity): """Representation of a Genius Hub switch.""" @property diff --git a/homeassistant/components/hdmi_cec/switch.py b/homeassistant/components/hdmi_cec/switch.py index 0fcf9c01c8f..aaaa2b83054 100644 --- a/homeassistant/components/hdmi_cec/switch.py +++ b/homeassistant/components/hdmi_cec/switch.py @@ -1,7 +1,7 @@ """Support for HDMI CEC devices as switches.""" import logging -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.const import STATE_OFF, STATE_ON, STATE_STANDBY from . import ATTR_NEW, CecDevice @@ -22,7 +22,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(entities, True) -class CecSwitchDevice(CecDevice, SwitchDevice): +class CecSwitchDevice(CecDevice, SwitchEntity): """Representation of a HDMI device as a Switch.""" def __init__(self, device, logical) -> None: diff --git a/homeassistant/components/hikvisioncam/switch.py b/homeassistant/components/hikvisioncam/switch.py index f86853a5468..2e924135bd4 100644 --- a/homeassistant/components/hikvisioncam/switch.py +++ b/homeassistant/components/hikvisioncam/switch.py @@ -5,7 +5,7 @@ import hikvision.api from hikvision.error import HikvisionError, MissingParamError import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -59,7 +59,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([HikvisionMotionSwitch(name, hikvision_cam)]) -class HikvisionMotionSwitch(SwitchDevice): +class HikvisionMotionSwitch(SwitchEntity): """Representation of a switch to toggle on/off motion detection.""" def __init__(self, name, hikvision_cam): diff --git a/homeassistant/components/hive/switch.py b/homeassistant/components/hive/switch.py index 53e1ec6a069..734581b0db3 100644 --- a/homeassistant/components/hive/switch.py +++ b/homeassistant/components/hive/switch.py @@ -1,5 +1,5 @@ """Support for the Hive switches.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DATA_HIVE, DOMAIN, HiveEntity, refresh_system @@ -16,7 +16,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devs) -class HiveDevicePlug(HiveEntity, SwitchDevice): +class HiveDevicePlug(HiveEntity, SwitchEntity): """Hive Active Plug.""" @property diff --git a/homeassistant/components/homekit_controller/switch.py b/homeassistant/components/homekit_controller/switch.py index 61595b504ca..32c7fd8515e 100644 --- a/homeassistant/components/homekit_controller/switch.py +++ b/homeassistant/components/homekit_controller/switch.py @@ -7,7 +7,7 @@ from aiohomekit.model.characteristics import ( IsConfiguredValues, ) -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback from . import KNOWN_DEVICES, HomeKitEntity @@ -21,7 +21,7 @@ ATTR_IS_CONFIGURED = "is_configured" ATTR_REMAINING_DURATION = "remaining_duration" -class HomeKitSwitch(HomeKitEntity, SwitchDevice): +class HomeKitSwitch(HomeKitEntity, SwitchEntity): """Representation of a Homekit switch.""" def get_characteristic_types(self): @@ -49,7 +49,7 @@ class HomeKitSwitch(HomeKitEntity, SwitchDevice): return {OUTLET_IN_USE: outlet_in_use} -class HomeKitValve(HomeKitEntity, SwitchDevice): +class HomeKitValve(HomeKitEntity, SwitchEntity): """Represents a valve in an irrigation system.""" def get_characteristic_types(self): diff --git a/homeassistant/components/homematic/switch.py b/homeassistant/components/homematic/switch.py index 53679818083..afde1ac8527 100644 --- a/homeassistant/components/homematic/switch.py +++ b/homeassistant/components/homematic/switch.py @@ -1,7 +1,7 @@ """Support for HomeMatic switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from .const import ATTR_DISCOVER_DEVICES from .entity import HMDevice @@ -22,7 +22,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class HMSwitch(HMDevice, SwitchDevice): +class HMSwitch(HMDevice, SwitchEntity): """Representation of a HomeMatic switch.""" @property diff --git a/homeassistant/components/homematicip_cloud/switch.py b/homeassistant/components/homematicip_cloud/switch.py index 79f7b9dfa5c..f000aef0695 100644 --- a/homeassistant/components/homematicip_cloud/switch.py +++ b/homeassistant/components/homematicip_cloud/switch.py @@ -15,7 +15,7 @@ from homematicip.aio.device import ( ) from homematicip.aio.group import AsyncExtendedLinkedSwitchingGroup, AsyncSwitchingGroup -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType @@ -67,7 +67,7 @@ async def async_setup_entry( async_add_entities(entities) -class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice): +class HomematicipSwitch(HomematicipGenericDevice, SwitchEntity): """representation of a HomematicIP Cloud switch device.""" def __init__(self, hap: HomematicipHAP, device) -> None: @@ -88,7 +88,7 @@ class HomematicipSwitch(HomematicipGenericDevice, SwitchDevice): await self._device.turn_off() -class HomematicipGroupSwitch(HomematicipGenericDevice, SwitchDevice): +class HomematicipGroupSwitch(HomematicipGenericDevice, SwitchEntity): """representation of a HomematicIP switching group.""" def __init__(self, hap: HomematicipHAP, device, post: str = "Group") -> None: @@ -145,7 +145,7 @@ class HomematicipSwitchMeasuring(HomematicipSwitch): return round(self._device.energyCounter) -class HomematicipMultiSwitch(HomematicipGenericDevice, SwitchDevice): +class HomematicipMultiSwitch(HomematicipGenericDevice, SwitchEntity): """Representation of a HomematicIP Cloud multi switch device.""" def __init__(self, hap: HomematicipHAP, device, channel: int) -> None: diff --git a/homeassistant/components/huawei_lte/switch.py b/homeassistant/components/huawei_lte/switch.py index 44d2da0c898..45b179f470f 100644 --- a/homeassistant/components/huawei_lte/switch.py +++ b/homeassistant/components/huawei_lte/switch.py @@ -8,7 +8,7 @@ import attr from homeassistant.components.switch import ( DEVICE_CLASS_SWITCH, DOMAIN as SWITCH_DOMAIN, - SwitchDevice, + SwitchEntity, ) from homeassistant.const import CONF_URL @@ -30,7 +30,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): @attr.s -class HuaweiLteBaseSwitch(HuaweiLteBaseEntity, SwitchDevice): +class HuaweiLteBaseSwitch(HuaweiLteBaseEntity, SwitchEntity): """Huawei LTE switch device base class.""" key: str diff --git a/homeassistant/components/hydrawise/switch.py b/homeassistant/components/hydrawise/switch.py index aa3780060c3..577fde85d37 100644 --- a/homeassistant/components/hydrawise/switch.py +++ b/homeassistant/components/hydrawise/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -47,7 +47,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class HydrawiseSwitch(HydrawiseEntity, SwitchDevice): +class HydrawiseSwitch(HydrawiseEntity, SwitchEntity): """A switch implementation for Hydrawise device.""" def __init__(self, default_watering_timer, *args): diff --git a/homeassistant/components/iaqualink/switch.py b/homeassistant/components/iaqualink/switch.py index 8efb473cf54..b71253ade12 100644 --- a/homeassistant/components/iaqualink/switch.py +++ b/homeassistant/components/iaqualink/switch.py @@ -1,7 +1,7 @@ """Support for Aqualink pool feature switches.""" import logging -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.typing import HomeAssistantType @@ -23,7 +23,7 @@ async def async_setup_entry( async_add_entities(devs, True) -class HassAqualinkSwitch(AqualinkEntity, SwitchDevice): +class HassAqualinkSwitch(AqualinkEntity, SwitchEntity): """Representation of a switch.""" @property diff --git a/homeassistant/components/ihc/switch.py b/homeassistant/components/ihc/switch.py index 15994f13eb2..8f72ac3bab8 100644 --- a/homeassistant/components/ihc/switch.py +++ b/homeassistant/components/ihc/switch.py @@ -1,5 +1,5 @@ """Support for IHC switches.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import IHC_CONTROLLER, IHC_INFO from .const import CONF_OFF_ID, CONF_ON_ID @@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class IHCSwitch(IHCDevice, SwitchDevice): +class IHCSwitch(IHCDevice, SwitchEntity): """Representation of an IHC switch.""" def __init__( diff --git a/homeassistant/components/insteon/switch.py b/homeassistant/components/insteon/switch.py index c88d31d2f91..3a0668459c9 100644 --- a/homeassistant/components/insteon/switch.py +++ b/homeassistant/components/insteon/switch.py @@ -1,7 +1,7 @@ """Support for INSTEON dimmers via PowerLinc Modem.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from .insteon_entity import InsteonEntity @@ -32,7 +32,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([new_entity]) -class InsteonSwitchDevice(InsteonEntity, SwitchDevice): +class InsteonSwitchDevice(InsteonEntity, SwitchEntity): """A Class for an Insteon device.""" @property @@ -49,7 +49,7 @@ class InsteonSwitchDevice(InsteonEntity, SwitchDevice): self._insteon_device_state.off() -class InsteonOpenClosedDevice(InsteonEntity, SwitchDevice): +class InsteonOpenClosedDevice(InsteonEntity, SwitchEntity): """A Class for an Insteon device.""" @property diff --git a/homeassistant/components/isy994/switch.py b/homeassistant/components/isy994/switch.py index aadd4428abd..d5339960282 100644 --- a/homeassistant/components/isy994/switch.py +++ b/homeassistant/components/isy994/switch.py @@ -2,7 +2,7 @@ import logging from typing import Callable -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.helpers.typing import ConfigType from . import ISY994_NODES, ISY994_PROGRAMS, ISYDevice @@ -25,7 +25,7 @@ def setup_platform( add_entities(devices) -class ISYSwitchDevice(ISYDevice, SwitchDevice): +class ISYSwitchDevice(ISYDevice, SwitchEntity): """Representation of an ISY994 switch device.""" @property diff --git a/homeassistant/components/juicenet/switch.py b/homeassistant/components/juicenet/switch.py index 30bb5b22814..5f2d16fa39d 100644 --- a/homeassistant/components/juicenet/switch.py +++ b/homeassistant/components/juicenet/switch.py @@ -1,7 +1,7 @@ """Support for monitoring juicenet/juicepoint/juicebox based EVSE switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN, JuicenetDevice @@ -19,7 +19,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devs) -class JuicenetChargeNowSwitch(JuicenetDevice, SwitchDevice): +class JuicenetChargeNowSwitch(JuicenetDevice, SwitchEntity): """Implementation of a Juicenet switch.""" def __init__(self, device, hass): diff --git a/homeassistant/components/kankun/switch.py b/homeassistant/components/kankun/switch.py index d9f4db62572..ce179515e88 100644 --- a/homeassistant/components/kankun/switch.py +++ b/homeassistant/components/kankun/switch.py @@ -4,7 +4,7 @@ import logging import requests import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -58,7 +58,7 @@ def setup_platform(hass, config, add_entities_callback, discovery_info=None): add_entities_callback(devices) -class KankunSwitch(SwitchDevice): +class KankunSwitch(SwitchEntity): """Representation of a Kankun Wifi switch.""" def __init__(self, hass, name, host, port, path, user, passwd): diff --git a/homeassistant/components/knx/switch.py b/homeassistant/components/knx/switch.py index ae798bf4c08..3f06221cea5 100644 --- a/homeassistant/components/knx/switch.py +++ b/homeassistant/components/knx/switch.py @@ -2,7 +2,7 @@ import voluptuous as vol from xknx.devices import Switch as XknxSwitch -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_ADDRESS, CONF_NAME from homeassistant.core import callback import homeassistant.helpers.config_validation as cv @@ -52,7 +52,7 @@ def async_add_entities_config(hass, config, async_add_entities): async_add_entities([KNXSwitch(switch)]) -class KNXSwitch(SwitchDevice): +class KNXSwitch(SwitchEntity): """Representation of a KNX switch.""" def __init__(self, device): diff --git a/homeassistant/components/lcn/switch.py b/homeassistant/components/lcn/switch.py index a2adda95b3b..e441ce40383 100644 --- a/homeassistant/components/lcn/switch.py +++ b/homeassistant/components/lcn/switch.py @@ -1,7 +1,7 @@ """Support for LCN switches.""" import pypck -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import CONF_ADDRESS from . import LcnDevice @@ -34,7 +34,7 @@ async def async_setup_platform( async_add_entities(devices) -class LcnOutputSwitch(LcnDevice, SwitchDevice): +class LcnOutputSwitch(LcnDevice, SwitchEntity): """Representation of a LCN switch for output ports.""" def __init__(self, config, address_connection): @@ -79,7 +79,7 @@ class LcnOutputSwitch(LcnDevice, SwitchDevice): self.async_write_ha_state() -class LcnRelaySwitch(LcnDevice, SwitchDevice): +class LcnRelaySwitch(LcnDevice, SwitchEntity): """Representation of a LCN switch for relay ports.""" def __init__(self, config, address_connection): diff --git a/homeassistant/components/lightwave/switch.py b/homeassistant/components/lightwave/switch.py index 16c2aa53462..7fa075a0834 100644 --- a/homeassistant/components/lightwave/switch.py +++ b/homeassistant/components/lightwave/switch.py @@ -1,5 +1,5 @@ """Support for LightwaveRF switches.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import CONF_NAME from . import LIGHTWAVE_LINK @@ -20,7 +20,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(switches) -class LWRFSwitch(SwitchDevice): +class LWRFSwitch(SwitchEntity): """Representation of a LightWaveRF switch.""" def __init__(self, name, device_id, lwlink): diff --git a/homeassistant/components/linode/switch.py b/homeassistant/components/linode/switch.py index deb561a5e32..c9207ec1be7 100644 --- a/homeassistant/components/linode/switch.py +++ b/homeassistant/components/linode/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity import homeassistant.helpers.config_validation as cv from . import ( @@ -44,7 +44,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev, True) -class LinodeSwitch(SwitchDevice): +class LinodeSwitch(SwitchEntity): """Representation of a Linode Node switch.""" def __init__(self, li, node_id): diff --git a/homeassistant/components/litejet/switch.py b/homeassistant/components/litejet/switch.py index 7861378d42e..a734dc46d3e 100644 --- a/homeassistant/components/litejet/switch.py +++ b/homeassistant/components/litejet/switch.py @@ -2,7 +2,7 @@ import logging from homeassistant.components import litejet -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity ATTR_NUMBER = "number" @@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class LiteJetSwitch(SwitchDevice): +class LiteJetSwitch(SwitchEntity): """Representation of a single LiteJet switch.""" def __init__(self, hass, lj, i, name): diff --git a/homeassistant/components/lupusec/switch.py b/homeassistant/components/lupusec/switch.py index a6864f39ef7..d18fcd7c1f7 100644 --- a/homeassistant/components/lupusec/switch.py +++ b/homeassistant/components/lupusec/switch.py @@ -4,7 +4,7 @@ import logging import lupupy.constants as CONST -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN as LUPUSEC_DOMAIN, LupusecDevice @@ -29,7 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class LupusecSwitch(LupusecDevice, SwitchDevice): +class LupusecSwitch(LupusecDevice, SwitchEntity): """Representation of a Lupusec switch.""" def turn_on(self, **kwargs): diff --git a/homeassistant/components/lutron/switch.py b/homeassistant/components/lutron/switch.py index 64ca5e6f216..d03cb4a1953 100644 --- a/homeassistant/components/lutron/switch.py +++ b/homeassistant/components/lutron/switch.py @@ -1,7 +1,7 @@ """Support for Lutron switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice @@ -29,7 +29,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devs, True) -class LutronSwitch(LutronDevice, SwitchDevice): +class LutronSwitch(LutronDevice, SwitchEntity): """Representation of a Lutron Switch.""" def __init__(self, area_name, lutron_device, controller): @@ -63,7 +63,7 @@ class LutronSwitch(LutronDevice, SwitchDevice): self._prev_state = self._lutron_device.level > 0 -class LutronLed(LutronDevice, SwitchDevice): +class LutronLed(LutronDevice, SwitchEntity): """Representation of a Lutron Keypad LED.""" def __init__(self, area_name, keypad_name, scene_device, led_device, controller): diff --git a/homeassistant/components/lutron_caseta/switch.py b/homeassistant/components/lutron_caseta/switch.py index 23cd1db8f79..01e61cc9002 100644 --- a/homeassistant/components/lutron_caseta/switch.py +++ b/homeassistant/components/lutron_caseta/switch.py @@ -1,7 +1,7 @@ """Support for Lutron Caseta switches.""" import logging -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from . import LUTRON_CASETA_SMARTBRIDGE, LutronCasetaDevice @@ -22,7 +22,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= return True -class LutronCasetaLight(LutronCasetaDevice, SwitchDevice): +class LutronCasetaLight(LutronCasetaDevice, SwitchEntity): """Representation of a Lutron Caseta switch.""" async def async_turn_on(self, **kwargs): diff --git a/homeassistant/components/mfi/switch.py b/homeassistant/components/mfi/switch.py index 08ed841e7e1..d2ba2371303 100644 --- a/homeassistant/components/mfi/switch.py +++ b/homeassistant/components/mfi/switch.py @@ -5,7 +5,7 @@ from mficlient.client import FailedToLogin, MFiClient import requests import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -61,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class MfiSwitch(SwitchDevice): +class MfiSwitch(SwitchEntity): """Representation of an mFi switch-able device.""" def __init__(self, port): diff --git a/homeassistant/components/mochad/switch.py b/homeassistant/components/mochad/switch.py index 4ce8f676659..e7f1bee99f6 100644 --- a/homeassistant/components/mochad/switch.py +++ b/homeassistant/components/mochad/switch.py @@ -5,7 +5,7 @@ from pymochad import device from pymochad.exceptions import MochadException import voluptuous as vol -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import CONF_ADDRESS, CONF_DEVICES, CONF_NAME, CONF_PLATFORM from homeassistant.helpers import config_validation as cv @@ -36,7 +36,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return True -class MochadSwitch(SwitchDevice): +class MochadSwitch(SwitchEntity): """Representation of a X10 switch over Mochad.""" def __init__(self, hass, ctrl, dev): diff --git a/homeassistant/components/mqtt/switch.py b/homeassistant/components/mqtt/switch.py index bc1f4a038b4..44d028829d0 100644 --- a/homeassistant/components/mqtt/switch.py +++ b/homeassistant/components/mqtt/switch.py @@ -4,7 +4,7 @@ import logging import voluptuous as vol from homeassistant.components import mqtt, switch -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import ( CONF_DEVICE, CONF_ICON, @@ -104,7 +104,7 @@ class MqttSwitch( MqttAvailability, MqttDiscoveryUpdate, MqttEntityDeviceInfo, - SwitchDevice, + SwitchEntity, RestoreEntity, ): """Representation of a switch that can be toggled using MQTT.""" diff --git a/homeassistant/components/mysensors/switch.py b/homeassistant/components/mysensors/switch.py index 16bb1ee6deb..0da8bfe7030 100644 --- a/homeassistant/components/mysensors/switch.py +++ b/homeassistant/components/mysensors/switch.py @@ -2,7 +2,7 @@ import voluptuous as vol from homeassistant.components import mysensors -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON import homeassistant.helpers.config_validation as cv @@ -72,7 +72,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class MySensorsSwitch(mysensors.device.MySensorsEntity, SwitchDevice): +class MySensorsSwitch(mysensors.device.MySensorsEntity, SwitchEntity): """Representation of the value of a MySensors Switch child node.""" @property diff --git a/homeassistant/components/mystrom/switch.py b/homeassistant/components/mystrom/switch.py index ea91c9ba5d7..ab1207658ab 100644 --- a/homeassistant/components/mystrom/switch.py +++ b/homeassistant/components/mystrom/switch.py @@ -5,7 +5,7 @@ from pymystrom.exceptions import MyStromConnectionError from pymystrom.switch import MyStromSwitch as _MyStromSwitch import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv @@ -37,7 +37,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([MyStromSwitch(plug, name)]) -class MyStromSwitch(SwitchDevice): +class MyStromSwitch(SwitchEntity): """Representation of a myStrom switch/plug.""" def __init__(self, plug, name): diff --git a/homeassistant/components/n26/switch.py b/homeassistant/components/n26/switch.py index 6ec111720f3..155c9c0091b 100644 --- a/homeassistant/components/n26/switch.py +++ b/homeassistant/components/n26/switch.py @@ -1,7 +1,7 @@ """Support for N26 switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DEFAULT_SCAN_INTERVAL, DOMAIN from .const import CARD_STATE_ACTIVE, CARD_STATE_BLOCKED, DATA @@ -26,7 +26,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switch_entities) -class N26CardSwitch(SwitchDevice): +class N26CardSwitch(SwitchEntity): """Representation of a N26 card block/unblock switch.""" def __init__(self, api_data, card: dict): diff --git a/homeassistant/components/netio/switch.py b/homeassistant/components/netio/switch.py index 6baa3a63f9f..08a5b7df862 100644 --- a/homeassistant/components/netio/switch.py +++ b/homeassistant/components/netio/switch.py @@ -8,7 +8,7 @@ import voluptuous as vol from homeassistant import util from homeassistant.components.http import HomeAssistantView -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -125,7 +125,7 @@ class NetioApiView(HomeAssistantView): return self.json(True) -class NetioSwitch(SwitchDevice): +class NetioSwitch(SwitchEntity): """Provide a Netio linked switch.""" def __init__(self, netio, outlet, name): diff --git a/homeassistant/components/orvibo/switch.py b/homeassistant/components/orvibo/switch.py index 75a95e053ae..fec30cdade7 100644 --- a/homeassistant/components/orvibo/switch.py +++ b/homeassistant/components/orvibo/switch.py @@ -4,7 +4,7 @@ import logging from orvibo.s20 import S20, S20Exception, discover import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_DISCOVERY, CONF_HOST, @@ -62,7 +62,7 @@ def setup_platform(hass, config, add_entities_callback, discovery_info=None): add_entities_callback(switches) -class S20Switch(SwitchDevice): +class S20Switch(SwitchEntity): """Representation of an S20 switch.""" def __init__(self, name, s20): diff --git a/homeassistant/components/pcal9535a/switch.py b/homeassistant/components/pcal9535a/switch.py index 87c8ced1b0d..7b4cc919dbd 100644 --- a/homeassistant/components/pcal9535a/switch.py +++ b/homeassistant/components/pcal9535a/switch.py @@ -4,7 +4,7 @@ import logging from pcal9535a import PCAL9535A import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import DEVICE_DEFAULT_NAME import homeassistant.helpers.config_validation as cv @@ -58,7 +58,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class PCAL9535ASwitch(SwitchDevice): +class PCAL9535ASwitch(SwitchEntity): """Representation of a PCAL9535A output pin.""" def __init__(self, name, pin, invert_logic): diff --git a/homeassistant/components/pencom/switch.py b/homeassistant/components/pencom/switch.py index 5cd1f826629..0fcdd056b15 100644 --- a/homeassistant/components/pencom/switch.py +++ b/homeassistant/components/pencom/switch.py @@ -4,7 +4,7 @@ import logging from pencompy.pencompy import Pencompy import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv @@ -59,7 +59,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devs, True) -class PencomRelay(SwitchDevice): +class PencomRelay(SwitchEntity): """Representation of a pencom relay.""" def __init__(self, hub, board, addr, name): diff --git a/homeassistant/components/pi4ioe5v9xxxx/switch.py b/homeassistant/components/pi4ioe5v9xxxx/switch.py index a7c1e19074c..a147c7f310d 100644 --- a/homeassistant/components/pi4ioe5v9xxxx/switch.py +++ b/homeassistant/components/pi4ioe5v9xxxx/switch.py @@ -4,7 +4,7 @@ import logging from pi4ioe5v9xxxx import pi4ioe5v9xxxx # pylint: disable=import-error import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import DEVICE_DEFAULT_NAME import homeassistant.helpers.config_validation as cv @@ -51,7 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class Pi4ioe5v9Switch(SwitchDevice): +class Pi4ioe5v9Switch(SwitchEntity): """Representation of a pi4ioe5v9 IO expansion IO.""" def __init__(self, name, pin, invert_logic): diff --git a/homeassistant/components/pilight/switch.py b/homeassistant/components/pilight/switch.py index 0700b14e953..8fb2229f55c 100644 --- a/homeassistant/components/pilight/switch.py +++ b/homeassistant/components/pilight/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_SWITCHES import homeassistant.helpers.config_validation as cv @@ -27,5 +27,5 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class PilightSwitch(PilightBaseDevice, SwitchDevice): +class PilightSwitch(PilightBaseDevice, SwitchEntity): """Representation of a Pilight switch.""" diff --git a/homeassistant/components/pulseaudio_loopback/switch.py b/homeassistant/components/pulseaudio_loopback/switch.py index ec1adc7641b..45577fcd674 100644 --- a/homeassistant/components/pulseaudio_loopback/switch.py +++ b/homeassistant/components/pulseaudio_loopback/switch.py @@ -7,7 +7,7 @@ import socket import voluptuous as vol from homeassistant import util -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT import homeassistant.helpers.config_validation as cv @@ -137,7 +137,7 @@ class PAServer: return -1 -class PALoopbackSwitch(SwitchDevice): +class PALoopbackSwitch(SwitchEntity): """Representation the presence or absence of a PA loopback module.""" def __init__(self, hass, name, pa_server, sink_name, source_name): diff --git a/homeassistant/components/qwikswitch/__init__.py b/homeassistant/components/qwikswitch/__init__.py index 850429c1752..eea02fb9f54 100644 --- a/homeassistant/components/qwikswitch/__init__.py +++ b/homeassistant/components/qwikswitch/__init__.py @@ -103,7 +103,7 @@ class QSToggleEntity(QSEntity): Implemented: - QSLight extends QSToggleEntity and Light[2] (ToggleEntity[1]) - - QSSwitch extends QSToggleEntity and SwitchDevice[3] (ToggleEntity[1]) + - QSSwitch extends QSToggleEntity and SwitchEntity[3] (ToggleEntity[1]) [1] /helpers/entity.py [2] /components/light/__init__.py diff --git a/homeassistant/components/qwikswitch/switch.py b/homeassistant/components/qwikswitch/switch.py index 2d970a59a2a..61ef13f9e7a 100644 --- a/homeassistant/components/qwikswitch/switch.py +++ b/homeassistant/components/qwikswitch/switch.py @@ -1,5 +1,5 @@ """Support for Qwikswitch relays.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN as QWIKSWITCH, QSToggleEntity @@ -14,5 +14,5 @@ async def async_setup_platform(hass, _, add_entities, discovery_info=None): add_entities(devs) -class QSSwitch(QSToggleEntity, SwitchDevice): +class QSSwitch(QSToggleEntity, SwitchEntity): """Switch based on a Qwikswitch relay module.""" diff --git a/homeassistant/components/rachio/switch.py b/homeassistant/components/rachio/switch.py index 764f87e924c..f9cfa6ab122 100644 --- a/homeassistant/components/rachio/switch.py +++ b/homeassistant/components/rachio/switch.py @@ -3,7 +3,7 @@ from abc import abstractmethod from datetime import timedelta import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -79,7 +79,7 @@ def _create_entities(hass, config_entry): return entities -class RachioSwitch(RachioDevice, SwitchDevice): +class RachioSwitch(RachioDevice, SwitchEntity): """Represent a Rachio state that can be toggled.""" def __init__(self, controller, poll=True): diff --git a/homeassistant/components/rainbird/switch.py b/homeassistant/components/rainbird/switch.py index 7f589401e3c..1fd162c07b7 100644 --- a/homeassistant/components/rainbird/switch.py +++ b/homeassistant/components/rainbird/switch.py @@ -5,7 +5,7 @@ import logging from pyrainbird import AvailableStations, RainbirdController import voluptuous as vol -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import ATTR_ENTITY_ID, CONF_FRIENDLY_NAME, CONF_TRIGGER_TIME from homeassistant.helpers import config_validation as cv @@ -67,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class RainBirdSwitch(SwitchDevice): +class RainBirdSwitch(SwitchEntity): """Representation of a Rain Bird switch.""" def __init__(self, controller: RainbirdController, zone, time, name): diff --git a/homeassistant/components/raincloud/switch.py b/homeassistant/components/raincloud/switch.py index f85ed884ca9..d6733412cac 100644 --- a/homeassistant/components/raincloud/switch.py +++ b/homeassistant/components/raincloud/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ATTR_ATTRIBUTION, CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -45,7 +45,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class RainCloudSwitch(RainCloudEntity, SwitchDevice): +class RainCloudSwitch(RainCloudEntity, SwitchEntity): """A switch implementation for raincloud device.""" def __init__(self, default_watering_timer, *args): diff --git a/homeassistant/components/rainmachine/switch.py b/homeassistant/components/rainmachine/switch.py index b93f607f853..936aa8f1f0e 100644 --- a/homeassistant/components/rainmachine/switch.py +++ b/homeassistant/components/rainmachine/switch.py @@ -4,7 +4,7 @@ import logging from regenmaschine.errors import RequestError -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import ATTR_ID from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -111,7 +111,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities, True) -class RainMachineSwitch(RainMachineEntity, SwitchDevice): +class RainMachineSwitch(RainMachineEntity, SwitchEntity): """A class to represent a generic RainMachine switch.""" def __init__(self, rainmachine, switch_data): diff --git a/homeassistant/components/raspyrfm/switch.py b/homeassistant/components/raspyrfm/switch.py index ec07119b96a..cd4e28e1f10 100644 --- a/homeassistant/components/raspyrfm/switch.py +++ b/homeassistant/components/raspyrfm/switch.py @@ -12,7 +12,7 @@ from raspyrfm_client.device_implementations.gateway.manufacturer.gateway_constan from raspyrfm_client.device_implementations.manufacturer_constants import Manufacturer import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -87,7 +87,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switch_entities) -class RaspyRFMSwitch(SwitchDevice): +class RaspyRFMSwitch(SwitchEntity): """Representation of a RaspyRFM switch.""" def __init__(self, raspyrfm_client, name: str, gateway, controlunit): diff --git a/homeassistant/components/recswitch/switch.py b/homeassistant/components/recswitch/switch.py index c242f23dfdd..9c6ac8f9508 100644 --- a/homeassistant/components/recswitch/switch.py +++ b/homeassistant/components/recswitch/switch.py @@ -5,7 +5,7 @@ import logging from pyrecswitch import RSNetwork, RSNetworkError import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME import homeassistant.helpers.config_validation as cv @@ -40,7 +40,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities([RecSwitchSwitch(device, device_name, mac_address)]) -class RecSwitchSwitch(SwitchDevice): +class RecSwitchSwitch(SwitchEntity): """Representation of a recswitch device.""" def __init__(self, device, device_name, mac_address): diff --git a/homeassistant/components/rest/switch.py b/homeassistant/components/rest/switch.py index 84d503bb09e..ab880201072 100644 --- a/homeassistant/components/rest/switch.py +++ b/homeassistant/components/rest/switch.py @@ -6,7 +6,7 @@ import aiohttp import async_timeout import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HEADERS, CONF_METHOD, @@ -109,7 +109,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= _LOGGER.error("No route to resource/endpoint: %s", resource) -class RestSwitch(SwitchDevice): +class RestSwitch(SwitchEntity): """Representation of a switch that can be toggled using REST.""" def __init__( diff --git a/homeassistant/components/rflink/switch.py b/homeassistant/components/rflink/switch.py index 83c335f0f03..266f9a4625e 100644 --- a/homeassistant/components/rflink/switch.py +++ b/homeassistant/components/rflink/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv @@ -69,5 +69,5 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(devices_from_config(config)) -class RflinkSwitch(SwitchableRflinkDevice, SwitchDevice): +class RflinkSwitch(SwitchableRflinkDevice, SwitchEntity): """Representation of a Rflink switch.""" diff --git a/homeassistant/components/rfxtrx/switch.py b/homeassistant/components/rfxtrx/switch.py index 05e4a37ab44..960dc7dd33a 100644 --- a/homeassistant/components/rfxtrx/switch.py +++ b/homeassistant/components/rfxtrx/switch.py @@ -4,7 +4,7 @@ import logging import RFXtrx as rfxtrxmod import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME, STATE_ON from homeassistant.helpers import config_validation as cv from homeassistant.helpers.restore_state import RestoreEntity @@ -68,7 +68,7 @@ def setup_platform(hass, config, add_entities_callback, discovery_info=None): RECEIVED_EVT_SUBSCRIBERS.append(switch_update) -class RfxtrxSwitch(RfxtrxDevice, SwitchDevice, RestoreEntity): +class RfxtrxSwitch(RfxtrxDevice, SwitchEntity, RestoreEntity): """Representation of a RFXtrx switch.""" async def async_added_to_hass(self): diff --git a/homeassistant/components/ring/switch.py b/homeassistant/components/ring/switch.py index e2f1882adf6..09627b50965 100644 --- a/homeassistant/components/ring/switch.py +++ b/homeassistant/components/ring/switch.py @@ -4,7 +4,7 @@ import logging import requests -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback import homeassistant.util.dt as dt_util @@ -36,7 +36,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(switches) -class BaseRingSwitch(RingEntityMixin, SwitchDevice): +class BaseRingSwitch(RingEntityMixin, SwitchEntity): """Represents a switch for controlling an aspect of a ring device.""" def __init__(self, config_entry_id, device, device_type): diff --git a/homeassistant/components/rpi_rf/switch.py b/homeassistant/components/rpi_rf/switch.py index 5c09111c1cb..78c2153a7b3 100644 --- a/homeassistant/components/rpi_rf/switch.py +++ b/homeassistant/components/rpi_rf/switch.py @@ -5,7 +5,7 @@ from threading import RLock import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME, CONF_SWITCHES, EVENT_HOMEASSISTANT_STOP import homeassistant.helpers.config_validation as cv @@ -73,7 +73,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, lambda event: rfdevice.cleanup()) -class RPiRFSwitch(SwitchDevice): +class RPiRFSwitch(SwitchEntity): """Representation of a GPIO RF switch.""" def __init__( diff --git a/homeassistant/components/satel_integra/switch.py b/homeassistant/components/satel_integra/switch.py index 46f4de2784f..e747b2474ae 100644 --- a/homeassistant/components/satel_integra/switch.py +++ b/homeassistant/components/satel_integra/switch.py @@ -1,7 +1,7 @@ """Support for Satel Integra modifiable outputs represented as switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -39,7 +39,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(devices) -class SatelIntegraSwitch(SwitchDevice): +class SatelIntegraSwitch(SwitchEntity): """Representation of an Satel switch.""" def __init__(self, controller, device_number, device_name, code): diff --git a/homeassistant/components/scsgate/switch.py b/homeassistant/components/scsgate/switch.py index d5c85a5a84f..da69eb0b058 100644 --- a/homeassistant/components/scsgate/switch.py +++ b/homeassistant/components/scsgate/switch.py @@ -5,7 +5,7 @@ from scsgate.messages import ScenarioTriggeredMessage, StateMessage from scsgate.tasks import ToggleStatusTask import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME import homeassistant.helpers.config_validation as cv @@ -80,7 +80,7 @@ def _setup_scenario_switches(logger, config, scsgate, hass): scsgate.add_device(switch) -class SCSGateSwitch(SwitchDevice): +class SCSGateSwitch(SwitchEntity): """Representation of a SCSGate switch.""" def __init__(self, scs_id, name, logger, scsgate): diff --git a/homeassistant/components/skybell/switch.py b/homeassistant/components/skybell/switch.py index 03ea74a2340..97a1d2a4c00 100644 --- a/homeassistant/components/skybell/switch.py +++ b/homeassistant/components/skybell/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -41,7 +41,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(sensors, True) -class SkybellSwitch(SkybellDevice, SwitchDevice): +class SkybellSwitch(SkybellDevice, SwitchEntity): """A switch implementation for Skybell devices.""" def __init__(self, device, switch_type): diff --git a/homeassistant/components/smappee/switch.py b/homeassistant/components/smappee/switch.py index cb7a1e8a395..6f6481d65f9 100644 --- a/homeassistant/components/smappee/switch.py +++ b/homeassistant/components/smappee/switch.py @@ -1,7 +1,7 @@ """Support for interacting with Smappee Comport Plugs.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DATA_SMAPPEE @@ -34,7 +34,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(dev) -class SmappeeSwitch(SwitchDevice): +class SmappeeSwitch(SwitchEntity): """Representation of a Smappee Comport Plug.""" def __init__(self, smappee, name, location_id, switch_id): diff --git a/homeassistant/components/smartthings/switch.py b/homeassistant/components/smartthings/switch.py index eb9c9c90c4b..ff70648ddcf 100644 --- a/homeassistant/components/smartthings/switch.py +++ b/homeassistant/components/smartthings/switch.py @@ -3,7 +3,7 @@ from typing import Optional, Sequence from pysmartthings import Attribute, Capability -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import SmartThingsEntity from .const import DATA_BROKERS, DOMAIN @@ -29,7 +29,7 @@ def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]: return None -class SmartThingsSwitch(SmartThingsEntity, SwitchDevice): +class SmartThingsSwitch(SmartThingsEntity, SwitchEntity): """Define a SmartThings switch.""" async def async_turn_off(self, **kwargs) -> None: diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py index 578b97c801e..18effc563bb 100644 --- a/homeassistant/components/snmp/switch.py +++ b/homeassistant/components/snmp/switch.py @@ -16,7 +16,7 @@ from pysnmp.hlapi.asyncio import ( ) import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -126,7 +126,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class SnmpSwitch(SwitchDevice): +class SnmpSwitch(SwitchEntity): """Representation of a SNMP switch.""" def __init__( diff --git a/homeassistant/components/somfy/switch.py b/homeassistant/components/somfy/switch.py index bc31d68ec1d..e96c91ecaea 100644 --- a/homeassistant/components/somfy/switch.py +++ b/homeassistant/components/somfy/switch.py @@ -2,7 +2,7 @@ from pymfy.api.devices.camera_protect import CameraProtect from pymfy.api.devices.category import Category -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import API, DEVICES, DOMAIN, SomfyEntity @@ -23,7 +23,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(await hass.async_add_executor_job(get_shutters), True) -class SomfyCameraShutter(SomfyEntity, SwitchDevice): +class SomfyCameraShutter(SomfyEntity, SwitchEntity): """Representation of a Somfy Camera Shutter device.""" def __init__(self, device, api): diff --git a/homeassistant/components/sony_projector/switch.py b/homeassistant/components/sony_projector/switch.py index e68bed34cfa..e14d74dd2c0 100644 --- a/homeassistant/components/sony_projector/switch.py +++ b/homeassistant/components/sony_projector/switch.py @@ -4,7 +4,7 @@ import logging import pysdcp import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON import homeassistant.helpers.config_validation as cv @@ -38,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): return True -class SonyProjector(SwitchDevice): +class SonyProjector(SwitchEntity): """Represents a Sony Projector as a switch.""" def __init__(self, sdcp_connection, name): diff --git a/homeassistant/components/spider/switch.py b/homeassistant/components/spider/switch.py index b02c38c84aa..58a45cf7b4d 100644 --- a/homeassistant/components/spider/switch.py +++ b/homeassistant/components/spider/switch.py @@ -1,7 +1,7 @@ """Support for Spider switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN as SPIDER_DOMAIN @@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class SpiderPowerPlug(SwitchDevice): +class SpiderPowerPlug(SwitchEntity): """Representation of a Spider Power Plug.""" def __init__(self, api, power_plug): diff --git a/homeassistant/components/starline/switch.py b/homeassistant/components/starline/switch.py index 920fe686d9a..c50a7bb4973 100644 --- a/homeassistant/components/starline/switch.py +++ b/homeassistant/components/starline/switch.py @@ -1,5 +1,5 @@ """Support for StarLine switch.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from .account import StarlineAccount, StarlineDevice from .const import DOMAIN @@ -30,7 +30,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class StarlineSwitch(StarlineEntity, SwitchDevice): +class StarlineSwitch(StarlineEntity, SwitchEntity): """Representation of a StarLine switch.""" def __init__( diff --git a/homeassistant/components/supla/switch.py b/homeassistant/components/supla/switch.py index 556c1b69a53..61f218b75d9 100644 --- a/homeassistant/components/supla/switch.py +++ b/homeassistant/components/supla/switch.py @@ -3,7 +3,7 @@ import logging from pprint import pformat from homeassistant.components.supla import SuplaChannel -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity _LOGGER = logging.getLogger(__name__) @@ -18,7 +18,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([SuplaSwitch(device) for device in discovery_info]) -class SuplaSwitch(SuplaChannel, SwitchDevice): +class SuplaSwitch(SuplaChannel, SwitchEntity): """Representation of a Supla Switch.""" def turn_on(self, **kwargs): diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index 3884b90c464..1d9b54a0424 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -78,7 +78,7 @@ async def async_unload_entry(hass, entry): return await hass.data[DOMAIN].async_unload_entry(entry) -class SwitchDevice(ToggleEntity): +class SwitchEntity(ToggleEntity): """Representation of a switch.""" @property @@ -112,3 +112,15 @@ class SwitchDevice(ToggleEntity): def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" return None + + +class SwitchDevice(SwitchEntity): + """Representation of a switch (for backwards compatibility).""" + + def __init_subclass__(cls, **kwargs): + """Print deprecation warning.""" + super().__init_subclass__(**kwargs) + _LOGGER.warning( + "SwitchDevice is deprecated, modify %s to extend SwitchEntity", + cls.__name__, + ) diff --git a/homeassistant/components/switchbot/switch.py b/homeassistant/components/switchbot/switch.py index f0cbecc8968..6d32f8cfd10 100644 --- a/homeassistant/components/switchbot/switch.py +++ b/homeassistant/components/switchbot/switch.py @@ -6,7 +6,7 @@ from typing import Any, Dict import switchbot import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_MAC, CONF_NAME, CONF_PASSWORD import homeassistant.helpers.config_validation as cv from homeassistant.helpers.restore_state import RestoreEntity @@ -32,7 +32,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([SwitchBot(mac_addr, name, password)]) -class SwitchBot(SwitchDevice, RestoreEntity): +class SwitchBot(SwitchEntity, RestoreEntity): """Representation of a Switchbot.""" def __init__(self, mac, name, password) -> None: diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index ea32183b511..c2254968901 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -12,7 +12,7 @@ from aioswitcher.consts import ( WAITING_TEXT, ) -from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchDevice +from homeassistant.components.switch import ATTR_CURRENT_POWER_W, SwitchEntity from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.typing import HomeAssistantType @@ -53,7 +53,7 @@ async def async_setup_platform( async_add_entities([SwitcherControl(hass.data[DOMAIN][DATA_DEVICE])]) -class SwitcherControl(SwitchDevice): +class SwitcherControl(SwitchEntity): """Home Assistant switch entity.""" def __init__(self, device_data: "SwitcherV2Device") -> None: diff --git a/homeassistant/components/switchmate/switch.py b/homeassistant/components/switchmate/switch.py index 268115434cf..e09e42fe75b 100644 --- a/homeassistant/components/switchmate/switch.py +++ b/homeassistant/components/switchmate/switch.py @@ -6,7 +6,7 @@ import logging import switchmate import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_MAC, CONF_NAME import homeassistant.helpers.config_validation as cv @@ -34,7 +34,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None) -> None: add_entities([SwitchmateEntity(mac_addr, name, flip_on_off)], True) -class SwitchmateEntity(SwitchDevice): +class SwitchmateEntity(SwitchEntity): """Representation of a Switchmate.""" def __init__(self, mac, name, flip_on_off) -> None: diff --git a/homeassistant/components/tahoma/switch.py b/homeassistant/components/tahoma/switch.py index 9f98e711ac9..13aa70c66d3 100644 --- a/homeassistant/components/tahoma/switch.py +++ b/homeassistant/components/tahoma/switch.py @@ -1,7 +1,7 @@ """Support for Tahoma switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import STATE_OFF, STATE_ON from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice @@ -22,7 +22,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class TahomaSwitch(TahomaDevice, SwitchDevice): +class TahomaSwitch(TahomaDevice, SwitchEntity): """Representation a Tahoma Switch.""" def __init__(self, tahoma_device, controller): diff --git a/homeassistant/components/telnet/switch.py b/homeassistant/components/telnet/switch.py index a99fe044c46..e4d93d9f685 100644 --- a/homeassistant/components/telnet/switch.py +++ b/homeassistant/components/telnet/switch.py @@ -8,7 +8,7 @@ import voluptuous as vol from homeassistant.components.switch import ( ENTITY_ID_FORMAT, PLATFORM_SCHEMA, - SwitchDevice, + SwitchEntity, ) from homeassistant.const import ( CONF_COMMAND_OFF, @@ -81,7 +81,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class TelnetSwitch(SwitchDevice): +class TelnetSwitch(SwitchEntity): """Representation of a switch that can be toggled using telnet commands.""" def __init__( diff --git a/homeassistant/components/template/switch.py b/homeassistant/components/template/switch.py index f96ed5479b9..0ec0eca553a 100644 --- a/homeassistant/components/template/switch.py +++ b/homeassistant/components/template/switch.py @@ -6,7 +6,7 @@ import voluptuous as vol from homeassistant.components.switch import ( ENTITY_ID_FORMAT, PLATFORM_SCHEMA, - SwitchDevice, + SwitchEntity, ) from homeassistant.const import ( ATTR_ENTITY_ID, @@ -96,7 +96,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(switches) -class SwitchTemplate(SwitchDevice): +class SwitchTemplate(SwitchEntity): """Representation of a Template switch.""" def __init__( diff --git a/homeassistant/components/tesla/switch.py b/homeassistant/components/tesla/switch.py index 716836821c4..5e9c2aa9031 100644 --- a/homeassistant/components/tesla/switch.py +++ b/homeassistant/components/tesla/switch.py @@ -1,7 +1,7 @@ """Support for Tesla charger switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import STATE_OFF, STATE_ON from . import DOMAIN as TESLA_DOMAIN, TeslaDevice @@ -24,7 +24,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities(entities, True) -class ChargerSwitch(TeslaDevice, SwitchDevice): +class ChargerSwitch(TeslaDevice, SwitchEntity): """Representation of a Tesla charger switch.""" def __init__(self, tesla_device, controller, config_entry): @@ -54,7 +54,7 @@ class ChargerSwitch(TeslaDevice, SwitchDevice): self._state = STATE_ON if self.tesla_device.is_charging() else STATE_OFF -class RangeSwitch(TeslaDevice, SwitchDevice): +class RangeSwitch(TeslaDevice, SwitchEntity): """Representation of a Tesla max range charging switch.""" def __init__(self, tesla_device, controller, config_entry): @@ -84,7 +84,7 @@ class RangeSwitch(TeslaDevice, SwitchDevice): self._state = bool(self.tesla_device.is_maxrange()) -class UpdateSwitch(TeslaDevice, SwitchDevice): +class UpdateSwitch(TeslaDevice, SwitchEntity): """Representation of a Tesla update switch.""" def __init__(self, tesla_device, controller, config_entry): @@ -118,7 +118,7 @@ class UpdateSwitch(TeslaDevice, SwitchDevice): self._state = bool(self.controller.get_updates(car_id)) -class SentryModeSwitch(TeslaDevice, SwitchDevice): +class SentryModeSwitch(TeslaDevice, SwitchEntity): """Representation of a Tesla sentry mode switch.""" async def async_turn_on(self, **kwargs): diff --git a/homeassistant/components/tplink/switch.py b/homeassistant/components/tplink/switch.py index 59d993477df..344f9cd96b0 100644 --- a/homeassistant/components/tplink/switch.py +++ b/homeassistant/components/tplink/switch.py @@ -7,7 +7,7 @@ from pyHS100 import SmartDeviceException, SmartPlug from homeassistant.components.switch import ( ATTR_CURRENT_POWER_W, ATTR_TODAY_ENERGY_KWH, - SwitchDevice, + SwitchEntity, ) from homeassistant.const import ATTR_VOLTAGE import homeassistant.helpers.device_registry as dr @@ -43,7 +43,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_ent return True -class SmartPlugSwitch(SwitchDevice): +class SmartPlugSwitch(SwitchEntity): """Representation of a TPLink Smart Plug switch.""" def __init__(self, smartplug: SmartPlug): diff --git a/homeassistant/components/tradfri/switch.py b/homeassistant/components/tradfri/switch.py index fffbf320c7e..cf23ffeb445 100644 --- a/homeassistant/components/tradfri/switch.py +++ b/homeassistant/components/tradfri/switch.py @@ -1,5 +1,5 @@ """Support for IKEA Tradfri switches.""" -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from .base_class import TradfriBaseDevice from .const import CONF_GATEWAY_ID, KEY_API, KEY_GATEWAY @@ -20,7 +20,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class TradfriSwitch(TradfriBaseDevice, SwitchDevice): +class TradfriSwitch(TradfriBaseDevice, SwitchEntity): """The platform class required by Home Assistant.""" def __init__(self, device, api, gateway_id): diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index 17cf5ae873a..30684c16da5 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -1,5 +1,5 @@ """Support for Tuya switches.""" -from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchDevice +from homeassistant.components.switch import ENTITY_ID_FORMAT, SwitchEntity from . import DATA_TUYA, TuyaDevice @@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class TuyaSwitch(TuyaDevice, SwitchDevice): +class TuyaSwitch(TuyaDevice, SwitchEntity): """Tuya Switch Device.""" def __init__(self, tuya): diff --git a/homeassistant/components/unifi/switch.py b/homeassistant/components/unifi/switch.py index b562b8bd746..ea39c82853a 100644 --- a/homeassistant/components/unifi/switch.py +++ b/homeassistant/components/unifi/switch.py @@ -1,7 +1,7 @@ """Support for devices connected to UniFi POE.""" import logging -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.restore_state import RestoreEntity @@ -125,7 +125,7 @@ def add_entities(controller, async_add_entities, previously_known_poe_clients): async_add_entities(switches) -class UniFiPOEClientSwitch(UniFiClient, SwitchDevice, RestoreEntity): +class UniFiPOEClientSwitch(UniFiClient, SwitchEntity, RestoreEntity): """Representation of a client that uses POE.""" DOMAIN = DOMAIN @@ -220,7 +220,7 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchDevice, RestoreEntity): await self.async_remove() -class UniFiBlockClientSwitch(UniFiClient, SwitchDevice): +class UniFiBlockClientSwitch(UniFiClient, SwitchEntity): """Representation of a blockable client.""" DOMAIN = DOMAIN diff --git a/homeassistant/components/upcloud/switch.py b/homeassistant/components/upcloud/switch.py index 5cb1d86671e..1d0984cdddb 100644 --- a/homeassistant/components/upcloud/switch.py +++ b/homeassistant/components/upcloud/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import STATE_OFF import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import dispatcher_send @@ -28,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices, True) -class UpCloudSwitch(UpCloudServerEntity, SwitchDevice): +class UpCloudSwitch(UpCloudServerEntity, SwitchEntity): """Representation of an UpCloud server switch.""" def turn_on(self, **kwargs): diff --git a/homeassistant/components/velbus/switch.py b/homeassistant/components/velbus/switch.py index 64d4b7c17f8..91746b1513e 100644 --- a/homeassistant/components/velbus/switch.py +++ b/homeassistant/components/velbus/switch.py @@ -3,7 +3,7 @@ import logging from velbus.util import VelbusException -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import VelbusEntity from .const import DOMAIN @@ -22,7 +22,7 @@ async def async_setup_entry(hass, entry, async_add_entities): async_add_entities(entities) -class VelbusSwitch(VelbusEntity, SwitchDevice): +class VelbusSwitch(VelbusEntity, SwitchEntity): """Representation of a switch.""" @property diff --git a/homeassistant/components/vera/switch.py b/homeassistant/components/vera/switch.py index a7ae6d45573..0a9a94d6372 100644 --- a/homeassistant/components/vera/switch.py +++ b/homeassistant/components/vera/switch.py @@ -5,7 +5,7 @@ from typing import Callable, List from homeassistant.components.switch import ( DOMAIN as PLATFORM_DOMAIN, ENTITY_ID_FORMAT, - SwitchDevice, + SwitchEntity, ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -33,7 +33,7 @@ async def async_setup_entry( ) -class VeraSwitch(VeraDevice, SwitchDevice): +class VeraSwitch(VeraDevice, SwitchEntity): """Representation of a Vera Switch.""" def __init__(self, vera_device, controller): diff --git a/homeassistant/components/verisure/switch.py b/homeassistant/components/verisure/switch.py index 2df250303c5..8025b22f402 100644 --- a/homeassistant/components/verisure/switch.py +++ b/homeassistant/components/verisure/switch.py @@ -2,7 +2,7 @@ import logging from time import monotonic -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import CONF_SMARTPLUGS, HUB as hub @@ -25,7 +25,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class VerisureSmartplug(SwitchDevice): +class VerisureSmartplug(SwitchEntity): """Representation of a Verisure smartplug.""" def __init__(self, device_id): diff --git a/homeassistant/components/versasense/switch.py b/homeassistant/components/versasense/switch.py index 4b44cb7aa2a..78eadffea34 100644 --- a/homeassistant/components/versasense/switch.py +++ b/homeassistant/components/versasense/switch.py @@ -1,7 +1,7 @@ """Support for VersaSense actuator peripheral.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN from .const import ( @@ -42,7 +42,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= async_add_entities(actuator_list) -class VActuator(SwitchDevice): +class VActuator(SwitchEntity): """Representation of an Actuator.""" def __init__(self, peripheral, parent_name, unit, measurement, consumer): diff --git a/homeassistant/components/vesync/switch.py b/homeassistant/components/vesync/switch.py index 6ab5c0c4368..fb6e83227e9 100644 --- a/homeassistant/components/vesync/switch.py +++ b/homeassistant/components/vesync/switch.py @@ -1,7 +1,7 @@ """Support for Etekcity VeSync switches.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -55,7 +55,7 @@ def _async_setup_entities(devices, async_add_entities): async_add_entities(dev_list, update_before_add=True) -class VeSyncSwitchHA(VeSyncDevice, SwitchDevice): +class VeSyncSwitchHA(VeSyncDevice, SwitchEntity): """Representation of a VeSync switch.""" def __init__(self, plug): @@ -90,7 +90,7 @@ class VeSyncSwitchHA(VeSyncDevice, SwitchDevice): self.smartplug.update_energy() -class VeSyncLightSwitch(VeSyncDevice, SwitchDevice): +class VeSyncLightSwitch(VeSyncDevice, SwitchEntity): """Handle representation of VeSync Light Switch.""" def __init__(self, switch): diff --git a/homeassistant/components/vultr/switch.py b/homeassistant/components/vultr/switch.py index da79652ec5b..a9c43717a71 100644 --- a/homeassistant/components/vultr/switch.py +++ b/homeassistant/components/vultr/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv @@ -50,7 +50,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([VultrSwitch(vultr, subscription, name)], True) -class VultrSwitch(SwitchDevice): +class VultrSwitch(SwitchEntity): """Representation of a Vultr subscription switch.""" def __init__(self, vultr, subscription, name): diff --git a/homeassistant/components/wake_on_lan/switch.py b/homeassistant/components/wake_on_lan/switch.py index 8200a0309fa..e3af8f146f1 100644 --- a/homeassistant/components/wake_on_lan/switch.py +++ b/homeassistant/components/wake_on_lan/switch.py @@ -6,7 +6,7 @@ import subprocess as sp import voluptuous as vol import wakeonlan -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_BROADCAST_ADDRESS, CONF_HOST, CONF_MAC, CONF_NAME import homeassistant.helpers.config_validation as cv from homeassistant.helpers.script import Script @@ -42,7 +42,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): ) -class WolSwitch(SwitchDevice): +class WolSwitch(SwitchEntity): """Representation of a wake on lan switch.""" def __init__(self, hass, name, host, mac_address, off_action, broadcast_address): diff --git a/homeassistant/components/wemo/switch.py b/homeassistant/components/wemo/switch.py index 4b6d99da200..203c495e974 100644 --- a/homeassistant/components/wemo/switch.py +++ b/homeassistant/components/wemo/switch.py @@ -5,7 +5,7 @@ import logging import async_timeout -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.const import STATE_OFF, STATE_ON, STATE_STANDBY, STATE_UNKNOWN from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.util import convert @@ -47,7 +47,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) -class WemoSwitch(SwitchDevice): +class WemoSwitch(SwitchEntity): """Representation of a WeMo switch.""" def __init__(self, device): diff --git a/homeassistant/components/wirelesstag/switch.py b/homeassistant/components/wirelesstag/switch.py index 79242394f7f..9027f92aec0 100644 --- a/homeassistant/components/wirelesstag/switch.py +++ b/homeassistant/components/wirelesstag/switch.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_MONITORED_CONDITIONS import homeassistant.helpers.config_validation as cv @@ -49,7 +49,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches, True) -class WirelessTagSwitch(WirelessTagBaseSensor, SwitchDevice): +class WirelessTagSwitch(WirelessTagBaseSensor, SwitchEntity): """A switch implementation for Wireless Sensor Tags.""" def __init__(self, api, tag, switch_type): diff --git a/homeassistant/components/wled/switch.py b/homeassistant/components/wled/switch.py index 85a1f261d94..440819927b1 100644 --- a/homeassistant/components/wled/switch.py +++ b/homeassistant/components/wled/switch.py @@ -2,7 +2,7 @@ import logging from typing import Any, Callable, Dict, List, Optional -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import HomeAssistantType @@ -37,7 +37,7 @@ async def async_setup_entry( async_add_entities(switches, True) -class WLEDSwitch(WLEDDeviceEntity, SwitchDevice): +class WLEDSwitch(WLEDDeviceEntity, SwitchEntity): """Defines a WLED switch.""" def __init__( diff --git a/homeassistant/components/xiaomi_aqara/switch.py b/homeassistant/components/xiaomi_aqara/switch.py index 90201e9c452..e711eab46fb 100644 --- a/homeassistant/components/xiaomi_aqara/switch.py +++ b/homeassistant/components/xiaomi_aqara/switch.py @@ -1,7 +1,7 @@ """Support for Xiaomi Aqara binary sensors.""" import logging -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import PY_XIAOMI_GATEWAY, XiaomiDevice @@ -79,7 +79,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(devices) -class XiaomiGenericSwitch(XiaomiDevice, SwitchDevice): +class XiaomiGenericSwitch(XiaomiDevice, SwitchEntity): """Representation of a XiaomiPlug.""" def __init__(self, device, name, data_key, supports_power_consumption, xiaomi_hub): diff --git a/homeassistant/components/xiaomi_miio/switch.py b/homeassistant/components/xiaomi_miio/switch.py index c66f9b745f5..d8552244ce8 100644 --- a/homeassistant/components/xiaomi_miio/switch.py +++ b/homeassistant/components/xiaomi_miio/switch.py @@ -13,7 +13,7 @@ from miio import ( # pylint: disable=import-error from miio.powerstrip import PowerMode # pylint: disable=import-error import voluptuous as vol -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_MODE, @@ -217,7 +217,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= ) -class XiaomiPlugGenericSwitch(SwitchDevice): +class XiaomiPlugGenericSwitch(SwitchEntity): """Representation of a Xiaomi Plug Generic.""" def __init__(self, name, plug, model, unique_id): diff --git a/homeassistant/components/zha/switch.py b/homeassistant/components/zha/switch.py index 328d9959ad2..9a7fc7aa6b0 100644 --- a/homeassistant/components/zha/switch.py +++ b/homeassistant/components/zha/switch.py @@ -6,7 +6,7 @@ from typing import Any, List from zigpy.zcl.clusters.general import OnOff from zigpy.zcl.foundation import Status -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.const import STATE_ON, STATE_UNAVAILABLE from homeassistant.core import State, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -41,7 +41,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): hass.data[DATA_ZHA][DATA_ZHA_DISPATCHERS].append(unsub) -class BaseSwitch(SwitchDevice): +class BaseSwitch(SwitchEntity): """Common base class for zha switches.""" def __init__(self, *args, **kwargs): diff --git a/homeassistant/components/zigbee/switch.py b/homeassistant/components/zigbee/switch.py index e29d2c045df..f5b73f5d328 100644 --- a/homeassistant/components/zigbee/switch.py +++ b/homeassistant/components/zigbee/switch.py @@ -1,7 +1,7 @@ """Support for Zigbee switches.""" import voluptuous as vol -from homeassistant.components.switch import SwitchDevice +from homeassistant.components.switch import SwitchEntity from . import DOMAIN, PLATFORM_SCHEMA, ZigBeeDigitalOut, ZigBeeDigitalOutConfig @@ -20,5 +20,5 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities([ZigBeeSwitch(ZigBeeDigitalOutConfig(config), zigbee_device)]) -class ZigBeeSwitch(ZigBeeDigitalOut, SwitchDevice): +class ZigBeeSwitch(ZigBeeDigitalOut, SwitchEntity): """Representation of a Zigbee Digital Out device.""" diff --git a/homeassistant/components/zoneminder/switch.py b/homeassistant/components/zoneminder/switch.py index 5eaf2ed4901..0428ddbf888 100644 --- a/homeassistant/components/zoneminder/switch.py +++ b/homeassistant/components/zoneminder/switch.py @@ -4,7 +4,7 @@ import logging import voluptuous as vol from zoneminder.monitor import MonitorState -from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice +from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.const import CONF_COMMAND_OFF, CONF_COMMAND_ON import homeassistant.helpers.config_validation as cv @@ -38,7 +38,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): add_entities(switches) -class ZMSwitchMonitors(SwitchDevice): +class ZMSwitchMonitors(SwitchEntity): """Representation of a ZoneMinder switch.""" icon = "mdi:record-rec" diff --git a/homeassistant/components/zwave/switch.py b/homeassistant/components/zwave/switch.py index 4956e99a40e..c5770bf7702 100644 --- a/homeassistant/components/zwave/switch.py +++ b/homeassistant/components/zwave/switch.py @@ -2,7 +2,7 @@ import logging import time -from homeassistant.components.switch import DOMAIN, SwitchDevice +from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.core import callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -27,7 +27,7 @@ def get_device(values, **kwargs): return ZwaveSwitch(values) -class ZwaveSwitch(ZWaveDeviceEntity, SwitchDevice): +class ZwaveSwitch(ZWaveDeviceEntity, SwitchEntity): """Representation of a Z-Wave switch.""" def __init__(self, values): diff --git a/tests/components/switch/test_init.py b/tests/components/switch/test_init.py index 07ab1d19f55..7a14d3ac117 100644 --- a/tests/components/switch/test_init.py +++ b/tests/components/switch/test_init.py @@ -103,3 +103,13 @@ async def test_switch_context(hass, hass_admin_user): assert state2 is not None assert state.state != state2.state assert state2.context.user_id == hass_admin_user.id + + +def test_deprecated_base_class(caplog): + """Test deprecated base class.""" + + class CustomSwitch(switch.SwitchDevice): + pass + + CustomSwitch() + assert "SwitchDevice is deprecated, modify CustomSwitch" in caplog.text