Rename LockDevice to LockEntity (#34594)
This commit is contained in:
parent
62bc02fdda
commit
b30d117e7d
30 changed files with 82 additions and 57 deletions
|
@ -1,7 +1,7 @@
|
||||||
"""Support for the Abode Security System locks."""
|
"""Support for the Abode Security System locks."""
|
||||||
import abodepy.helpers.constants as CONST
|
import abodepy.helpers.constants as CONST
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
|
|
||||||
from . import AbodeDevice
|
from . import AbodeDevice
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -19,7 +19,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
class AbodeLock(AbodeDevice, LockDevice):
|
class AbodeLock(AbodeDevice, LockEntity):
|
||||||
"""Representation of an Abode lock."""
|
"""Representation of an Abode lock."""
|
||||||
|
|
||||||
def lock(self, **kwargs):
|
def lock(self, **kwargs):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from august.activity import ActivityType
|
||||||
from august.lock import LockStatus
|
from august.lock import LockStatus
|
||||||
from august.util import update_lock_detail_from_activity
|
from august.util import update_lock_detail_from_activity
|
||||||
|
|
||||||
from homeassistant.components.lock import ATTR_CHANGED_BY, LockDevice
|
from homeassistant.components.lock import ATTR_CHANGED_BY, LockEntity
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL
|
from homeassistant.const import ATTR_BATTERY_LEVEL
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
@ -28,7 +28,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
async_add_entities(devices, True)
|
async_add_entities(devices, True)
|
||||||
|
|
||||||
|
|
||||||
class AugustLock(AugustEntityMixin, RestoreEntity, LockDevice):
|
class AugustLock(AugustEntityMixin, RestoreEntity, LockEntity):
|
||||||
"""Representation of an August lock."""
|
"""Representation of an August lock."""
|
||||||
|
|
||||||
def __init__(self, data, device):
|
def __init__(self, data, device):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
|
|
||||||
from bimmer_connected.state import LockState
|
from bimmer_connected.state import LockState
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import ATTR_ATTRIBUTION, STATE_LOCKED, STATE_UNLOCKED
|
||||||
|
|
||||||
from . import DOMAIN as BMW_DOMAIN
|
from . import DOMAIN as BMW_DOMAIN
|
||||||
|
@ -26,7 +26,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities(devices, True)
|
add_entities(devices, True)
|
||||||
|
|
||||||
|
|
||||||
class BMWLock(LockDevice):
|
class BMWLock(LockEntity):
|
||||||
"""Representation of a BMW vehicle lock."""
|
"""Representation of a BMW vehicle lock."""
|
||||||
|
|
||||||
def __init__(self, account, vehicle, attribute: str, sensor_name):
|
def __init__(self, account, vehicle, attribute: str, sensor_name):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""Demo lock platform that has two fake locks."""
|
"""Demo lock platform that has two fake locks."""
|
||||||
from homeassistant.components.lock import SUPPORT_OPEN, LockDevice
|
from homeassistant.components.lock import SUPPORT_OPEN, LockEntity
|
||||||
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
await async_setup_platform(hass, {}, async_add_entities)
|
await async_setup_platform(hass, {}, async_add_entities)
|
||||||
|
|
||||||
|
|
||||||
class DemoLock(LockDevice):
|
class DemoLock(LockEntity):
|
||||||
"""Representation of a Demo lock."""
|
"""Representation of a Demo lock."""
|
||||||
|
|
||||||
def __init__(self, name, state, openable=False):
|
def __init__(self, name, state, openable=False):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
|
|
||||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_LOCKED, STATE_UNLOCKED
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
conn.add_listener(async_add_service)
|
conn.add_listener(async_add_service)
|
||||||
|
|
||||||
|
|
||||||
class HomeKitLock(HomeKitEntity, LockDevice):
|
class HomeKitLock(HomeKitEntity, LockEntity):
|
||||||
"""Representation of a HomeKit Controller Lock."""
|
"""Representation of a HomeKit Controller Lock."""
|
||||||
|
|
||||||
def get_characteristic_types(self):
|
def get_characteristic_types(self):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Homematic locks."""
|
"""Support for Homematic locks."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.lock import SUPPORT_OPEN, LockDevice
|
from homeassistant.components.lock import SUPPORT_OPEN, LockEntity
|
||||||
|
|
||||||
from .const import ATTR_DISCOVER_DEVICES
|
from .const import ATTR_DISCOVER_DEVICES
|
||||||
from .entity import HMDevice
|
from .entity import HMDevice
|
||||||
|
@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities(devices, True)
|
add_entities(devices, True)
|
||||||
|
|
||||||
|
|
||||||
class HMLock(HMDevice, LockDevice):
|
class HMLock(HMDevice, LockEntity):
|
||||||
"""Representation of a Homematic lock aka KeyMatic."""
|
"""Representation of a Homematic lock aka KeyMatic."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from homeassistant.components.lock import DOMAIN, LockDevice
|
from homeassistant.components.lock import DOMAIN, LockEntity
|
||||||
from homeassistant.const import STATE_LOCKED, STATE_UNKNOWN, STATE_UNLOCKED
|
from homeassistant.const import STATE_LOCKED, STATE_UNKNOWN, STATE_UNLOCKED
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ def setup_platform(
|
||||||
add_entities(devices)
|
add_entities(devices)
|
||||||
|
|
||||||
|
|
||||||
class ISYLockDevice(ISYDevice, LockDevice):
|
class ISYLockDevice(ISYDevice, LockEntity):
|
||||||
"""Representation of an ISY994 lock device."""
|
"""Representation of an ISY994 lock device."""
|
||||||
|
|
||||||
def __init__(self, node) -> None:
|
def __init__(self, node) -> None:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for KEBA charging station switch."""
|
"""Support for KEBA charging station switch."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
async_add_entities(sensors)
|
async_add_entities(sensors)
|
||||||
|
|
||||||
|
|
||||||
class KebaLock(LockDevice):
|
class KebaLock(LockEntity):
|
||||||
"""The entity class for KEBA charging stations switch."""
|
"""The entity class for KEBA charging stations switch."""
|
||||||
|
|
||||||
def __init__(self, keba, name, entity_type):
|
def __init__(self, keba, name, entity_type):
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
from kiwiki import KiwiClient, KiwiException
|
from kiwiki import KiwiClient, KiwiException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
|
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ID,
|
ATTR_ID,
|
||||||
ATTR_LATITUDE,
|
ATTR_LATITUDE,
|
||||||
|
@ -47,7 +47,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities([KiwiLock(lock, kiwi) for lock in available_locks], True)
|
add_entities([KiwiLock(lock, kiwi) for lock in available_locks], True)
|
||||||
|
|
||||||
|
|
||||||
class KiwiLock(LockDevice):
|
class KiwiLock(LockEntity):
|
||||||
"""Representation of a Kiwi lock."""
|
"""Representation of a Kiwi lock."""
|
||||||
|
|
||||||
def __init__(self, kiwi_lock, client):
|
def __init__(self, kiwi_lock, client):
|
||||||
|
|
|
@ -25,6 +25,8 @@ from homeassistant.helpers.entity_component import EntityComponent
|
||||||
|
|
||||||
# mypy: allow-untyped-defs, no-check-untyped-defs
|
# mypy: allow-untyped-defs, no-check-untyped-defs
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ATTR_CHANGED_BY = "changed_by"
|
ATTR_CHANGED_BY = "changed_by"
|
||||||
|
|
||||||
DOMAIN = "lock"
|
DOMAIN = "lock"
|
||||||
|
@ -75,7 +77,7 @@ async def async_unload_entry(hass, entry):
|
||||||
return await hass.data[DOMAIN].async_unload_entry(entry)
|
return await hass.data[DOMAIN].async_unload_entry(entry)
|
||||||
|
|
||||||
|
|
||||||
class LockDevice(Entity):
|
class LockEntity(Entity):
|
||||||
"""Representation of a lock."""
|
"""Representation of a lock."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -134,3 +136,14 @@ class LockDevice(Entity):
|
||||||
if locked is None:
|
if locked is None:
|
||||||
return None
|
return None
|
||||||
return STATE_LOCKED if locked else STATE_UNLOCKED
|
return STATE_LOCKED if locked else STATE_UNLOCKED
|
||||||
|
|
||||||
|
|
||||||
|
class LockDevice(LockEntity):
|
||||||
|
"""Representation of a lock (for backwards compatibility)."""
|
||||||
|
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"LockDevice is deprecated, modify %s to extend LockEntity", cls.__name__,
|
||||||
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
|
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_ID, HTTP_OK
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_ID, HTTP_OK
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
_LOGGER.error("Error retrieving lock status during init: %s", response.text)
|
_LOGGER.error("Error retrieving lock status during init: %s", response.text)
|
||||||
|
|
||||||
|
|
||||||
class Lockitron(LockDevice):
|
class Lockitron(LockEntity):
|
||||||
"""Representation of a Lockitron lock."""
|
"""Representation of a Lockitron lock."""
|
||||||
|
|
||||||
LOCK_STATE = "lock"
|
LOCK_STATE = "lock"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import lock, mqtt
|
from homeassistant.components import lock, mqtt
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
@ -108,7 +108,7 @@ class MqttLock(
|
||||||
MqttAvailability,
|
MqttAvailability,
|
||||||
MqttDiscoveryUpdate,
|
MqttDiscoveryUpdate,
|
||||||
MqttEntityDeviceInfo,
|
MqttEntityDeviceInfo,
|
||||||
LockDevice,
|
LockEntity,
|
||||||
):
|
):
|
||||||
"""Representation of a lock that can be toggled using MQTT."""
|
"""Representation of a lock that can be toggled using MQTT."""
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import logging
|
||||||
from pynello.private import Nello
|
from pynello.private import Nello
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
|
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities([NelloLock(lock) for lock in nello.locations], True)
|
add_entities([NelloLock(lock) for lock in nello.locations], True)
|
||||||
|
|
||||||
|
|
||||||
class NelloLock(LockDevice):
|
class NelloLock(LockEntity):
|
||||||
"""Representation of a Nello lock."""
|
"""Representation of a Nello lock."""
|
||||||
|
|
||||||
def __init__(self, nello_lock):
|
def __init__(self, nello_lock):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from pynuki import NukiBridge
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, SUPPORT_OPEN, LockDevice
|
from homeassistant.components.lock import PLATFORM_SCHEMA, SUPPORT_OPEN, LockEntity
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_PORT, CONF_TOKEN
|
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_PORT, CONF_TOKEN
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.service import extract_entity_ids
|
from homeassistant.helpers.service import extract_entity_ids
|
||||||
|
@ -71,7 +71,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities(devices)
|
add_entities(devices)
|
||||||
|
|
||||||
|
|
||||||
class NukiLock(LockDevice):
|
class NukiLock(LockEntity):
|
||||||
"""Representation of a Nuki lock."""
|
"""Representation of a Nuki lock."""
|
||||||
|
|
||||||
def __init__(self, nuki_lock):
|
def __init__(self, nuki_lock):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Callable
|
||||||
import pysesame2
|
import pysesame2
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
|
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
|
@ -32,7 +32,7 @@ def setup_platform(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SesameDevice(LockDevice):
|
class SesameDevice(LockEntity):
|
||||||
"""Representation of a Sesame device."""
|
"""Representation of a Sesame device."""
|
||||||
|
|
||||||
def __init__(self, sesame: object) -> None:
|
def __init__(self, sesame: object) -> None:
|
||||||
|
|
|
@ -5,7 +5,7 @@ from simplipy.errors import SimplipyError
|
||||||
from simplipy.lock import LockStates
|
from simplipy.lock import LockStates
|
||||||
from simplipy.websocket import EVENT_LOCK_LOCKED, EVENT_LOCK_UNLOCKED
|
from simplipy.websocket import EVENT_LOCK_LOCKED, EVENT_LOCK_UNLOCKED
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from . import SimpliSafeEntity
|
from . import SimpliSafeEntity
|
||||||
|
@ -30,7 +30,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SimpliSafeLock(SimpliSafeEntity, LockDevice):
|
class SimpliSafeLock(SimpliSafeEntity, LockEntity):
|
||||||
"""Define a SimpliSafe lock."""
|
"""Define a SimpliSafe lock."""
|
||||||
|
|
||||||
def __init__(self, simplisafe, system, lock):
|
def __init__(self, simplisafe, system, lock):
|
||||||
|
|
|
@ -3,7 +3,7 @@ from typing import Optional, Sequence
|
||||||
|
|
||||||
from pysmartthings import Attribute, Capability
|
from pysmartthings import Attribute, Capability
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
|
|
||||||
from . import SmartThingsEntity
|
from . import SmartThingsEntity
|
||||||
from .const import DATA_BROKERS, DOMAIN
|
from .const import DATA_BROKERS, DOMAIN
|
||||||
|
@ -38,7 +38,7 @@ def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class SmartThingsLock(SmartThingsEntity, LockDevice):
|
class SmartThingsLock(SmartThingsEntity, LockEntity):
|
||||||
"""Define a SmartThings lock."""
|
"""Define a SmartThings lock."""
|
||||||
|
|
||||||
async def async_lock(self, **kwargs):
|
async def async_lock(self, **kwargs):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""Support for StarLine lock."""
|
"""Support for StarLine lock."""
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
|
|
||||||
from .account import StarlineAccount, StarlineDevice
|
from .account import StarlineAccount, StarlineDevice
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -19,7 +19,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
class StarlineLock(StarlineEntity, LockDevice):
|
class StarlineLock(StarlineEntity, LockEntity):
|
||||||
"""Representation of a StarLine lock."""
|
"""Representation of a StarLine lock."""
|
||||||
|
|
||||||
def __init__(self, account: StarlineAccount, device: StarlineDevice):
|
def __init__(self, account: StarlineAccount, device: StarlineDevice):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_LOCKED, STATE_UNLOCKED
|
||||||
|
|
||||||
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
|
from . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
|
||||||
|
@ -24,7 +24,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities(devices, True)
|
add_entities(devices, True)
|
||||||
|
|
||||||
|
|
||||||
class TahomaLock(TahomaDevice, LockDevice):
|
class TahomaLock(TahomaDevice, LockEntity):
|
||||||
"""Representation a Tahoma lock."""
|
"""Representation a Tahoma lock."""
|
||||||
|
|
||||||
def __init__(self, tahoma_device, controller):
|
def __init__(self, tahoma_device, controller):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
|
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_OPTIMISTIC,
|
CONF_OPTIMISTIC,
|
||||||
|
@ -72,7 +72,7 @@ async def async_setup_platform(hass, config, async_add_devices, discovery_info=N
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TemplateLock(LockDevice):
|
class TemplateLock(LockEntity):
|
||||||
"""Representation of a template lock."""
|
"""Representation of a template lock."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Tesla door locks."""
|
"""Support for Tesla door locks."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
||||||
|
|
||||||
from . import DOMAIN as TESLA_DOMAIN, TeslaDevice
|
from . import DOMAIN as TESLA_DOMAIN, TeslaDevice
|
||||||
|
@ -22,7 +22,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
class TeslaLock(TeslaDevice, LockDevice):
|
class TeslaLock(TeslaDevice, LockEntity):
|
||||||
"""Representation of a Tesla door lock."""
|
"""Representation of a Tesla door lock."""
|
||||||
|
|
||||||
def __init__(self, tesla_device, controller, config_entry):
|
def __init__(self, tesla_device, controller, config_entry):
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Callable, List
|
||||||
from homeassistant.components.lock import (
|
from homeassistant.components.lock import (
|
||||||
DOMAIN as PLATFORM_DOMAIN,
|
DOMAIN as PLATFORM_DOMAIN,
|
||||||
ENTITY_ID_FORMAT,
|
ENTITY_ID_FORMAT,
|
||||||
LockDevice,
|
LockEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
||||||
|
@ -36,7 +36,7 @@ async def async_setup_entry(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class VeraLock(VeraDevice, LockDevice):
|
class VeraLock(VeraDevice, LockEntity):
|
||||||
"""Representation of a Vera lock."""
|
"""Representation of a Vera lock."""
|
||||||
|
|
||||||
def __init__(self, vera_device, controller):
|
def __init__(self, vera_device, controller):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import logging
|
import logging
|
||||||
from time import monotonic, sleep
|
from time import monotonic, sleep
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import ATTR_CODE, STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import ATTR_CODE, STATE_LOCKED, STATE_UNLOCKED
|
||||||
|
|
||||||
from . import CONF_CODE_DIGITS, CONF_DEFAULT_LOCK_CODE, CONF_LOCKS, HUB as hub
|
from . import CONF_CODE_DIGITS, CONF_DEFAULT_LOCK_CODE, CONF_LOCKS, HUB as hub
|
||||||
|
@ -25,7 +25,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities(locks)
|
add_entities(locks)
|
||||||
|
|
||||||
|
|
||||||
class VerisureDoorlock(LockDevice):
|
class VerisureDoorlock(LockEntity):
|
||||||
"""Representation of a Verisure doorlock."""
|
"""Representation of a Verisure doorlock."""
|
||||||
|
|
||||||
def __init__(self, device_label):
|
def __init__(self, device_label):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Volvo On Call locks."""
|
"""Support for Volvo On Call locks."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
|
|
||||||
from . import DATA_KEY, VolvoEntity
|
from . import DATA_KEY, VolvoEntity
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
async_add_entities([VolvoLock(hass.data[DATA_KEY], *discovery_info)])
|
async_add_entities([VolvoLock(hass.data[DATA_KEY], *discovery_info)])
|
||||||
|
|
||||||
|
|
||||||
class VolvoLock(VolvoEntity, LockDevice):
|
class VolvoLock(VolvoEntity, LockEntity):
|
||||||
"""Represents a car lock."""
|
"""Represents a car lock."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
import pywink
|
import pywink
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_CODE,
|
ATTR_CODE,
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
|
@ -133,7 +133,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class WinkLockDevice(WinkDevice, LockDevice):
|
class WinkLockDevice(WinkDevice, LockEntity):
|
||||||
"""Representation of a Wink lock."""
|
"""Representation of a Wink lock."""
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Xiaomi Aqara locks."""
|
"""Support for Xiaomi Aqara locks."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.lock import LockDevice
|
from homeassistant.components.lock import LockEntity
|
||||||
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
|
@ -32,7 +32,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
async_add_entities(devices)
|
async_add_entities(devices)
|
||||||
|
|
||||||
|
|
||||||
class XiaomiAqaraLock(LockDevice, XiaomiDevice):
|
class XiaomiAqaraLock(LockEntity, XiaomiDevice):
|
||||||
"""Representation of a XiaomiAqaraLock."""
|
"""Representation of a XiaomiAqaraLock."""
|
||||||
|
|
||||||
def __init__(self, device, name, xiaomi_hub):
|
def __init__(self, device, name, xiaomi_hub):
|
||||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.components.lock import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
STATE_LOCKED,
|
STATE_LOCKED,
|
||||||
STATE_UNLOCKED,
|
STATE_UNLOCKED,
|
||||||
LockDevice,
|
LockEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
@ -49,7 +49,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
|
|
||||||
|
|
||||||
@STRICT_MATCH(channel_names=CHANNEL_DOORLOCK)
|
@STRICT_MATCH(channel_names=CHANNEL_DOORLOCK)
|
||||||
class ZhaDoorLock(ZhaEntity, LockDevice):
|
class ZhaDoorLock(ZhaEntity, LockEntity):
|
||||||
"""Representation of a ZHA lock."""
|
"""Representation of a ZHA lock."""
|
||||||
|
|
||||||
def __init__(self, unique_id, zha_device, channels, **kwargs):
|
def __init__(self, unique_id, zha_device, channels, **kwargs):
|
||||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.lock import DOMAIN, LockDevice
|
from homeassistant.components.lock import DOMAIN, LockEntity
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
@ -239,7 +239,7 @@ def get_device(node, values, **kwargs):
|
||||||
return ZwaveLock(values)
|
return ZwaveLock(values)
|
||||||
|
|
||||||
|
|
||||||
class ZwaveLock(ZWaveDeviceEntity, LockDevice):
|
class ZwaveLock(ZWaveDeviceEntity, LockEntity):
|
||||||
"""Representation of a Z-Wave Lock."""
|
"""Representation of a Z-Wave Lock."""
|
||||||
|
|
||||||
def __init__(self, values):
|
def __init__(self, values):
|
||||||
|
|
12
tests/components/lock/test_init.py
Normal file
12
tests/components/lock/test_init.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
"""The tests for Lock."""
|
||||||
|
from homeassistant.components import lock
|
||||||
|
|
||||||
|
|
||||||
|
def test_deprecated_base_class(caplog):
|
||||||
|
"""Test deprecated base class."""
|
||||||
|
|
||||||
|
class CustomLock(lock.LockDevice):
|
||||||
|
pass
|
||||||
|
|
||||||
|
CustomLock()
|
||||||
|
assert "LockDevice is deprecated, modify CustomLock" in caplog.text
|
|
@ -3,7 +3,7 @@ Provide a mock lock platform.
|
||||||
|
|
||||||
Call init before using it in your tests to ensure clean test data.
|
Call init before using it in your tests to ensure clean test data.
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.lock import SUPPORT_OPEN, LockDevice
|
from homeassistant.components.lock import SUPPORT_OPEN, LockEntity
|
||||||
|
|
||||||
from tests.common import MockEntity
|
from tests.common import MockEntity
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ async def async_setup_platform(
|
||||||
async_add_entities_callback(list(ENTITIES.values()))
|
async_add_entities_callback(list(ENTITIES.values()))
|
||||||
|
|
||||||
|
|
||||||
class MockLock(MockEntity, LockDevice):
|
class MockLock(MockEntity, LockEntity):
|
||||||
"""Mock Lock class."""
|
"""Mock Lock class."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Add table
Reference in a new issue