9static const char *
const TAG =
"lock";
16 return LockStateStrings::get_log_str(
static_cast<uint8_t
>(
state), 0);
24 call.set_state(
state);
32 ESP_LOGD(TAG,
"'%s' Opening.", this->
get_name().c_str());
35 ESP_LOGW(TAG,
"'%s' Does not support Open.", this->
get_name().c_str());
46#if defined(USE_LOCK) && defined(USE_CONTROLLER_REGISTRY)
79 if (ESPHOME_strcasecmp_P(
state, ESPHOME_PSTR(
"LOCKED")) == 0) {
81 }
else if (ESPHOME_strcasecmp_P(
state, ESPHOME_PSTR(
"UNLOCKED")) == 0) {
83 }
else if (ESPHOME_strcasecmp_P(
state, ESPHOME_PSTR(
"JAMMED")) == 0) {
85 }
else if (ESPHOME_strcasecmp_P(
state, ESPHOME_PSTR(
"LOCKING")) == 0) {
87 }
else if (ESPHOME_strcasecmp_P(
state, ESPHOME_PSTR(
"UNLOCKING")) == 0) {
89 }
else if (ESPHOME_strcasecmp_P(
state, ESPHOME_PSTR(
"NONE")) == 0) {
static void notify_lock_update(lock::Lock *obj)
bool next(T value)
Feeds the next item in the series to the deduplicator and returns false if this is a duplicate.
const StringRef & get_name() const
constexpr const char * c_str() const
This class is used to encode all control actions on a lock device.
const optional< LockState > & get_state() const
LockCall & set_state(LockState state)
Set the state of the lock device.
LockCall & set_state(const char *state)
Set the state of the lock device based on a string.
optional< LockState > state_
virtual void control(const LockCall &call)=0
Control the lock device, this is a virtual method that each lock integration must implement.
Deduplicator< LockState > publish_dedup_
void set_state_(LockState state)
Helper for lock/unlock convenience methods.
virtual void open_latch()
Perform the open latch action with hardware.
LockCall make_call()
Make a lock device control call, this is used to control the lock device, see the LockCall descriptio...
void lock()
Turn this lock on.
void publish_state(LockState state)
Publish a state to the front-end from the back-end.
void add_on_state_callback(std::function< void()> &&callback)
Set callback for state changes.
LockState state
The current reported state of the lock.
void unlock()
Turn this lock off.
LazyCallbackManager< void()> state_callback_
void open()
Open (unlatch) this lock.
bool supports_state(LockState state) const
bool get_supports_open() const
const LogString * lock_state_to_string(LockState state)
LockState
Enum for all states a lock can be in.
PROGMEM_STRING_TABLE(LockStateStrings, "UNKNOWN", "LOCKED", "UNLOCKED", "JAMMED", "LOCKING", "UNLOCKING")