Fix incorrect usage of ToggleEntity in switch platforms (#64620)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
parent
604a900658
commit
4c83ecd7bd
21 changed files with 44 additions and 51 deletions
|
@ -1,7 +1,7 @@
|
|||
"""Switch platform for Advantage Air integration."""
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
|
@ -28,7 +28,7 @@ async def async_setup_entry(
|
|||
async_add_entities(entities)
|
||||
|
||||
|
||||
class AdvantageAirFreshAir(AdvantageAirEntity, ToggleEntity):
|
||||
class AdvantageAirFreshAir(AdvantageAirEntity, SwitchEntity):
|
||||
"""Representation of Advantage Air fresh air control."""
|
||||
|
||||
_attr_icon = "mdi:air-filter"
|
||||
|
|
|
@ -4,11 +4,10 @@ from __future__ import annotations
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import bbb_gpio
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -44,7 +43,7 @@ def setup_platform(
|
|||
add_entities(switches)
|
||||
|
||||
|
||||
class BBBGPIOSwitch(ToggleEntity):
|
||||
class BBBGPIOSwitch(SwitchEntity):
|
||||
"""Representation of a BeagleBone Black GPIO."""
|
||||
|
||||
_attr_should_poll = False
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import annotations
|
|||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -34,7 +33,7 @@ async def async_setup_entry(
|
|||
) -> None:
|
||||
"""Set up Daikin climate based on config_entry."""
|
||||
daikin_api = hass.data[DAIKIN_DOMAIN][entry.entry_id]
|
||||
switches: list[ToggleEntity] = []
|
||||
switches: list[DaikinZoneSwitch | DaikinStreamerSwitch] = []
|
||||
if zones := daikin_api.device.zones:
|
||||
switches.extend(
|
||||
[
|
||||
|
@ -52,7 +51,7 @@ async def async_setup_entry(
|
|||
async_add_entities(switches)
|
||||
|
||||
|
||||
class DaikinZoneSwitch(ToggleEntity):
|
||||
class DaikinZoneSwitch(SwitchEntity):
|
||||
"""Representation of a zone."""
|
||||
|
||||
def __init__(self, daikin_api, zone_id):
|
||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
|||
from deluge_client import DelugeRPCClient, FailedToReconnectException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
|
@ -19,7 +19,6 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -63,7 +62,7 @@ def setup_platform(
|
|||
add_entities([DelugeSwitch(deluge_api, name)])
|
||||
|
||||
|
||||
class DelugeSwitch(ToggleEntity):
|
||||
class DelugeSwitch(SwitchEntity):
|
||||
"""Representation of a Deluge switch."""
|
||||
|
||||
def __init__(self, deluge_client, name):
|
||||
|
|
|
@ -3,11 +3,10 @@ from __future__ import annotations
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import CONF_ID, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -39,7 +38,7 @@ def setup_platform(
|
|||
add_entities([EnOceanSwitch(dev_id, dev_name, channel)])
|
||||
|
||||
|
||||
class EnOceanSwitch(EnOceanEntity, ToggleEntity):
|
||||
class EnOceanSwitch(EnOceanEntity, SwitchEntity):
|
||||
"""Representation of an EnOcean switch device."""
|
||||
|
||||
def __init__(self, dev_id, dev_name, channel):
|
||||
|
|
|
@ -3,11 +3,10 @@ from __future__ import annotations
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -35,7 +34,7 @@ def setup_platform(
|
|||
add_entities(switches, True)
|
||||
|
||||
|
||||
class GC100Switch(ToggleEntity):
|
||||
class GC100Switch(SwitchEntity):
|
||||
"""Represent a switch/relay from GC100."""
|
||||
|
||||
def __init__(self, name, port_addr, gc100):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Support for HLK-SW16 switches."""
|
||||
from homeassistant.components.switch import ToggleEntity
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -28,7 +28,7 @@ async def async_setup_entry(
|
|||
async_add_entities(devices_from_entities(hass, entry))
|
||||
|
||||
|
||||
class SW16Switch(SW16Device, ToggleEntity):
|
||||
class SW16Switch(SW16Device, SwitchEntity):
|
||||
"""Representation of a HLK-SW16 switch."""
|
||||
|
||||
@property
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Support for wired switches attached to a Konnected device."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_STATE,
|
||||
|
@ -12,7 +13,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo, ToggleEntity
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import (
|
||||
|
@ -42,7 +43,7 @@ async def async_setup_entry(
|
|||
async_add_entities(switches)
|
||||
|
||||
|
||||
class KonnectedSwitch(ToggleEntity):
|
||||
class KonnectedSwitch(SwitchEntity):
|
||||
"""Representation of a Konnected switch."""
|
||||
|
||||
def __init__(self, device_id, zone_num, data):
|
||||
|
|
|
@ -9,11 +9,10 @@ import busio
|
|||
import digitalio
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -65,7 +64,7 @@ def setup_platform(
|
|||
add_entities(switches)
|
||||
|
||||
|
||||
class MCP23017Switch(ToggleEntity):
|
||||
class MCP23017Switch(SwitchEntity):
|
||||
"""Representation of a MCP23017 output pin."""
|
||||
|
||||
def __init__(self, name, pin, invert_logic):
|
||||
|
|
|
@ -8,10 +8,11 @@ from typing import Any
|
|||
from pybotvac.exceptions import NeatoRobotException
|
||||
from pybotvac.robot import Robot
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory, ToggleEntity
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import NEATO_DOMAIN, NEATO_LOGIN, NEATO_ROBOTS, SCAN_INTERVAL_MINUTES
|
||||
|
@ -44,7 +45,7 @@ async def async_setup_entry(
|
|||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class NeatoConnectedSwitch(ToggleEntity):
|
||||
class NeatoConnectedSwitch(SwitchEntity):
|
||||
"""Neato Connected Switches."""
|
||||
|
||||
def __init__(self, neato: NeatoHub, robot: Robot, switch_type: str) -> None:
|
||||
|
|
|
@ -6,8 +6,8 @@ from typing import Any
|
|||
|
||||
from pycarwings2.pycarwings2 import Leaf
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -35,7 +35,7 @@ def setup_platform(
|
|||
add_entities(entities, True)
|
||||
|
||||
|
||||
class LeafClimateSwitch(LeafEntity, ToggleEntity):
|
||||
class LeafClimateSwitch(LeafEntity, SwitchEntity):
|
||||
"""Nissan Leaf Climate Control switch."""
|
||||
|
||||
def __init__(self, car: Leaf) -> None:
|
||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
|||
|
||||
from numato_gpio import NumatoGpioError
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICES,
|
||||
CONF_ID,
|
||||
|
@ -12,7 +13,6 @@ from homeassistant.const import (
|
|||
DEVICE_DEFAULT_NAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -64,7 +64,7 @@ def setup_platform(
|
|||
add_entities(switches, True)
|
||||
|
||||
|
||||
class NumatoGpioSwitch(ToggleEntity):
|
||||
class NumatoGpioSwitch(SwitchEntity):
|
||||
"""Representation of a Numato USB GPIO switch port."""
|
||||
|
||||
def __init__(self, name, device_id, port, invert_logic, api):
|
||||
|
|
|
@ -6,11 +6,10 @@ from typing import TYPE_CHECKING
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import CONF_ADDRESS, CONF_NAME, DEVICE_DEFAULT_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -90,7 +89,7 @@ def setup_platform(
|
|||
add_entities(switches)
|
||||
|
||||
|
||||
class I2CHatSwitch(ToggleEntity):
|
||||
class I2CHatSwitch(SwitchEntity):
|
||||
"""Representation a switch that uses a I2C-HAT digital output."""
|
||||
|
||||
I2C_HATS_MANAGER: I2CHatsManager | None = None
|
||||
|
|
|
@ -4,11 +4,10 @@ from __future__ import annotations
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import rpi_gpio
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import DEVICE_DEFAULT_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.reload import setup_reload_service
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
@ -49,7 +48,7 @@ def setup_platform(
|
|||
add_entities(switches)
|
||||
|
||||
|
||||
class RPiGPIOSwitch(ToggleEntity):
|
||||
class RPiGPIOSwitch(SwitchEntity):
|
||||
"""Representation of a Raspberry Pi GPIO."""
|
||||
|
||||
def __init__(self, name, port, invert_logic):
|
||||
|
|
|
@ -4,11 +4,10 @@ from __future__ import annotations
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import rpi_pfio
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
|
||||
from homeassistant.const import ATTR_NAME, DEVICE_DEFAULT_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -47,7 +46,7 @@ def setup_platform(
|
|||
add_entities(switches)
|
||||
|
||||
|
||||
class RPiPFIOSwitch(ToggleEntity):
|
||||
class RPiPFIOSwitch(SwitchEntity):
|
||||
"""Representation of a PiFace Digital Output."""
|
||||
|
||||
def __init__(self, port, name, invert_logic):
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Any
|
|||
|
||||
from synology_dsm.api.surveillance_station import SynoSurveillanceStation
|
||||
|
||||
from homeassistant.components.switch import ToggleEntity
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
@ -54,7 +54,7 @@ async def async_setup_entry(
|
|||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
class SynoDSMSurveillanceHomeModeToggle(SynologyDSMBaseEntity, ToggleEntity):
|
||||
class SynoDSMSurveillanceHomeModeToggle(SynologyDSMBaseEntity, SwitchEntity):
|
||||
"""Representation a Synology Surveillance Station Home Mode toggle."""
|
||||
|
||||
coordinator: DataUpdateCoordinator[dict[str, dict[str, bool]]]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""Support for Tellstick switches using Tellstick Net."""
|
||||
from homeassistant.components import switch, tellduslive
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .entry import TelldusLiveEntity
|
||||
|
@ -28,7 +28,7 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
|
||||
class TelldusLiveSwitch(TelldusLiveEntity, ToggleEntity):
|
||||
class TelldusLiveSwitch(TelldusLiveEntity, SwitchEntity):
|
||||
"""Representation of a Tellstick switch."""
|
||||
|
||||
@property
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""Support for Tellstick switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -39,7 +39,7 @@ def setup_platform(
|
|||
)
|
||||
|
||||
|
||||
class TellstickSwitch(TellstickDevice, ToggleEntity):
|
||||
class TellstickSwitch(TellstickDevice, SwitchEntity):
|
||||
"""Representation of a Tellstick switch."""
|
||||
|
||||
def _parse_ha_data(self, kwargs):
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""Support for setting the Transmission BitTorrent client Turtle Mode."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME, STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN, SWITCH_TYPES
|
||||
|
@ -30,7 +30,7 @@ async def async_setup_entry(
|
|||
async_add_entities(dev, True)
|
||||
|
||||
|
||||
class TransmissionSwitch(ToggleEntity):
|
||||
class TransmissionSwitch(SwitchEntity):
|
||||
"""Representation of a Transmission switch."""
|
||||
|
||||
def __init__(self, switch_type, switch_name, tm_client, name):
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""Support for Volvo heater."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -21,7 +21,7 @@ async def async_setup_platform(
|
|||
async_add_entities([VolvoSwitch(hass.data[DATA_KEY], *discovery_info)])
|
||||
|
||||
|
||||
class VolvoSwitch(VolvoEntity, ToggleEntity):
|
||||
class VolvoSwitch(VolvoEntity, SwitchEntity):
|
||||
"""Representation of a Volvo switch."""
|
||||
|
||||
@property
|
||||
|
|
|
@ -3,8 +3,8 @@ from __future__ import annotations
|
|||
|
||||
from xs1_api_client.api_constants import ActuatorType
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
|
@ -30,7 +30,7 @@ def setup_platform(
|
|||
add_entities(switch_entities)
|
||||
|
||||
|
||||
class XS1SwitchEntity(XS1DeviceEntity, ToggleEntity):
|
||||
class XS1SwitchEntity(XS1DeviceEntity, SwitchEntity):
|
||||
"""Representation of a XS1 switch actuator."""
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue