1 """Support for SwitchBot lock platform."""
6 from switchbot.const
import LockStatus
12 from .const
import CONF_LOCK_NIGHTLATCH, DEFAULT_LOCK_NIGHTLATCH
13 from .coordinator
import SwitchbotConfigEntry, SwitchbotDataUpdateCoordinator
14 from .entity
import SwitchbotEntity
19 entry: SwitchbotConfigEntry,
20 async_add_entities: AddEntitiesCallback,
22 """Set up Switchbot lock based on a config entry."""
23 force_nightlatch = entry.options.get(CONF_LOCK_NIGHTLATCH, DEFAULT_LOCK_NIGHTLATCH)
29 """Representation of a Switchbot lock."""
31 _attr_translation_key =
"lock"
33 _device: switchbot.SwitchbotLock
36 self, coordinator: SwitchbotDataUpdateCoordinator, force_nightlatch
38 """Initialize the entity."""
41 if self.
_device_device.is_night_latch_enabled()
or force_nightlatch:
45 """Update the entity attributes."""
46 status = self.
_device_device.get_lock_status()
51 LockStatus.LOCKING_STOP,
52 LockStatus.UNLOCKING_STOP,
61 """Unlock the lock."""
None unlock(self, **Any kwargs)
None lock(self, **Any kwargs)
None _async_update_attrs(self)
None async_open(self, **Any kwargs)
None __init__(self, SwitchbotDataUpdateCoordinator coordinator, force_nightlatch)
None async_unlock(self, **Any kwargs)
None async_lock(self, **Any kwargs)
None _async_update_attrs(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, SwitchbotConfigEntry entry, AddEntitiesCallback async_add_entities)