Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/abode/lock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for the Abode Security System locks."""
import abodepy.helpers.constants as CONST

from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import LockEntity

from . import AbodeDevice
from .const import DOMAIN
Expand All @@ -19,7 +19,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities)


class AbodeLock(AbodeDevice, LockDevice):
class AbodeLock(AbodeDevice, LockEntity):
"""Representation of an Abode lock."""

def lock(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/august/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from august.lock import LockStatus
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.core import callback
from homeassistant.helpers.restore_state import RestoreEntity
Expand All @@ -28,7 +28,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(devices, True)


class AugustLock(AugustEntityMixin, RestoreEntity, LockDevice):
class AugustLock(AugustEntityMixin, RestoreEntity, LockEntity):
"""Representation of an August lock."""

def __init__(self, data, device):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/bmw_connected_drive/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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 . import DOMAIN as BMW_DOMAIN
Expand All @@ -26,7 +26,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True)


class BMWLock(LockDevice):
class BMWLock(LockEntity):
"""Representation of a BMW vehicle lock."""

def __init__(self, account, vehicle, attribute: str, sensor_name):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/demo/lock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""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


Expand All @@ -19,7 +19,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
await async_setup_platform(hass, {}, async_add_entities)


class DemoLock(LockDevice):
class DemoLock(LockEntity):
"""Representation of a Demo lock."""

def __init__(self, name, state, openable=False):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/homekit_controller/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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.core import callback

Expand Down Expand Up @@ -34,7 +34,7 @@ def async_add_service(aid, service):
conn.add_listener(async_add_service)


class HomeKitLock(HomeKitEntity, LockDevice):
class HomeKitLock(HomeKitEntity, LockEntity):
"""Representation of a HomeKit Controller Lock."""

def get_characteristic_types(self):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/homematic/lock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for Homematic locks."""
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 .entity import HMDevice
Expand All @@ -21,7 +21,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True)


class HMLock(HMDevice, LockDevice):
class HMLock(HMDevice, LockEntity):
"""Representation of a Homematic lock aka KeyMatic."""

@property
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/isy994/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
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.helpers.typing import ConfigType

Expand All @@ -27,7 +27,7 @@ def setup_platform(
add_entities(devices)


class ISYLockDevice(ISYDevice, LockDevice):
class ISYLockDevice(ISYDevice, LockEntity):
"""Representation of an ISY994 lock device."""

def __init__(self, node) -> None:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/keba/lock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for KEBA charging station switch."""
import logging

from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import LockEntity

from . import DOMAIN

Expand All @@ -19,7 +19,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
async_add_entities(sensors)


class KebaLock(LockDevice):
class KebaLock(LockEntity):
"""The entity class for KEBA charging stations switch."""

def __init__(self, keba, name, entity_type):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/kiwi/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from kiwiki import KiwiClient, KiwiException
import voluptuous as vol

from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
from homeassistant.const import (
ATTR_ID,
ATTR_LATITUDE,
Expand Down Expand Up @@ -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)


class KiwiLock(LockDevice):
class KiwiLock(LockEntity):
"""Representation of a Kiwi lock."""

def __init__(self, kiwi_lock, client):
Expand Down
15 changes: 14 additions & 1 deletion homeassistant/components/lock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

# mypy: allow-untyped-defs, no-check-untyped-defs

_LOGGER = logging.getLogger(__name__)

ATTR_CHANGED_BY = "changed_by"

DOMAIN = "lock"
Expand Down Expand Up @@ -75,7 +77,7 @@ async def async_unload_entry(hass, entry):
return await hass.data[DOMAIN].async_unload_entry(entry)


class LockDevice(Entity):
class LockEntity(Entity):
"""Representation of a lock."""

@property
Expand Down Expand Up @@ -134,3 +136,14 @@ def state(self):
if locked is None:
return None
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 changes: 2 additions & 2 deletions homeassistant/components/lockitron/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import requests
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
import homeassistant.helpers.config_validation as cv

Expand All @@ -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)


class Lockitron(LockDevice):
class Lockitron(LockEntity):
"""Representation of a Lockitron lock."""

LOCK_STATE = "lock"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/mqtt/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import voluptuous as vol

from homeassistant.components import lock, mqtt
from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import LockEntity
from homeassistant.const import (
CONF_DEVICE,
CONF_NAME,
Expand Down Expand Up @@ -108,7 +108,7 @@ class MqttLock(
MqttAvailability,
MqttDiscoveryUpdate,
MqttEntityDeviceInfo,
LockDevice,
LockEntity,
):
"""Representation of a lock that can be toggled using MQTT."""

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/nello/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pynello.private import Nello
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
import homeassistant.helpers.config_validation as cv

Expand All @@ -27,7 +27,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities([NelloLock(lock) for lock in nello.locations], True)


class NelloLock(LockDevice):
class NelloLock(LockEntity):
"""Representation of a Nello lock."""

def __init__(self, nello_lock):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/nuki/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from requests.exceptions import RequestException
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
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.service import extract_entity_ids
Expand Down Expand Up @@ -71,7 +71,7 @@ def service_handler(service):
add_entities(devices)


class NukiLock(LockDevice):
class NukiLock(LockEntity):
"""Representation of a Nuki lock."""

def __init__(self, nuki_lock):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/sesame/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pysesame2
import voluptuous as vol

from homeassistant.components.lock import PLATFORM_SCHEMA, LockDevice
from homeassistant.components.lock import PLATFORM_SCHEMA, LockEntity
from homeassistant.const import (
ATTR_BATTERY_LEVEL,
CONF_API_KEY,
Expand Down Expand Up @@ -32,7 +32,7 @@ def setup_platform(
)


class SesameDevice(LockDevice):
class SesameDevice(LockEntity):
"""Representation of a Sesame device."""

def __init__(self, sesame: object) -> None:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/simplisafe/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from simplipy.lock import LockStates
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 . import SimpliSafeEntity
Expand All @@ -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."""

def __init__(self, simplisafe, system, lock):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/smartthings/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pysmartthings import Attribute, Capability

from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import LockEntity

from . import SmartThingsEntity
from .const import DATA_BROKERS, DOMAIN
Expand Down Expand Up @@ -38,7 +38,7 @@ def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
return None


class SmartThingsLock(SmartThingsEntity, LockDevice):
class SmartThingsLock(SmartThingsEntity, LockEntity):
"""Define a SmartThings lock."""

async def async_lock(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/starline/lock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Support for StarLine lock."""
from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import LockEntity

from .account import StarlineAccount, StarlineDevice
from .const import DOMAIN
Expand All @@ -19,7 +19,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
async_add_entities(entities)


class StarlineLock(StarlineEntity, LockDevice):
class StarlineLock(StarlineEntity, LockEntity):
"""Representation of a StarLine lock."""

def __init__(self, account: StarlineAccount, device: StarlineDevice):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/tahoma/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import timedelta
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 . import DOMAIN as TAHOMA_DOMAIN, TahomaDevice
Expand All @@ -24,7 +24,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
add_entities(devices, True)


class TahomaLock(TahomaDevice, LockDevice):
class TahomaLock(TahomaDevice, LockEntity):
"""Representation a Tahoma lock."""

def __init__(self, tahoma_device, controller):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/template/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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_NAME,
CONF_OPTIMISTIC,
Expand Down Expand Up @@ -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."""

def __init__(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/tesla/lock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Support for Tesla door locks."""
import logging

from homeassistant.components.lock import LockDevice
from homeassistant.components.lock import LockEntity
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED

from . import DOMAIN as TESLA_DOMAIN, TeslaDevice
Expand All @@ -22,7 +22,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
async_add_entities(entities, True)


class TeslaLock(TeslaDevice, LockDevice):
class TeslaLock(TeslaDevice, LockEntity):
"""Representation of a Tesla door lock."""

def __init__(self, tesla_device, controller, config_entry):
Expand Down
Loading