Home Assistant Unofficial Reference 2024.12.1
lock.py
Go to the documentation of this file.
1 """Support for INSTEON locks."""
2 
3 from typing import Any
4 
5 from homeassistant.components.lock import LockEntity
6 from homeassistant.config_entries import ConfigEntry
7 from homeassistant.const import Platform
8 from homeassistant.core import HomeAssistant, callback
9 from homeassistant.helpers.dispatcher import async_dispatcher_connect
10 from homeassistant.helpers.entity_platform import AddEntitiesCallback
11 
12 from .const import SIGNAL_ADD_ENTITIES
13 from .entity import InsteonEntity
14 from .utils import async_add_insteon_devices, async_add_insteon_entities
15 
16 
18  hass: HomeAssistant,
19  config_entry: ConfigEntry,
20  async_add_entities: AddEntitiesCallback,
21 ) -> None:
22  """Set up the Insteon locks from a config entry."""
23 
24  @callback
25  def async_add_insteon_lock_entities(discovery_info=None):
26  """Add the Insteon entities for the platform."""
28  hass, Platform.LOCK, InsteonLockEntity, async_add_entities, discovery_info
29  )
30 
31  signal = f"{SIGNAL_ADD_ENTITIES}_{Platform.LOCK}"
32  async_dispatcher_connect(hass, signal, async_add_insteon_lock_entities)
34  hass,
35  Platform.LOCK,
36  InsteonLockEntity,
37  async_add_entities,
38  )
39 
40 
42  """A Class for an Insteon lock entity."""
43 
44  @property
45  def is_locked(self) -> bool:
46  """Return the boolean response if the node is on."""
47  return bool(self._insteon_device_group_insteon_device_group.value)
48 
49  async def async_lock(self, **kwargs: Any) -> None:
50  """Lock the device."""
51  await self._insteon_device_insteon_device.async_lock()
52 
53  async def async_unlock(self, **kwargs: Any) -> None:
54  """Unlock the device."""
55  await self._insteon_device_insteon_device.async_unlock()
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: lock.py:21
None async_add_insteon_devices(HomeAssistant hass, Platform platform, type[InsteonEntity] entity_type, AddEntitiesCallback async_add_entities)
Definition: utils.py:436
None async_add_insteon_entities(HomeAssistant hass, Platform platform, type[InsteonEntity] entity_type, AddEntitiesCallback async_add_entities, dict[str, Any] discovery_info)
Definition: utils.py:420
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)
Definition: dispatcher.py:103