7 static const char *
const TAG =
"lock";
42 ESP_LOGD(TAG,
"'%s' Opening.", this->
get_name().c_str());
45 ESP_LOGW(TAG,
"'%s' Does not support Open.", this->
get_name().c_str());
61 ESP_LOGD(TAG,
"'%s' - Setting", this->parent_->get_name().c_str());
63 if (this->state_.has_value()) {
65 ESP_LOGD(TAG,
" State: %s", state_s);
67 this->parent_->control(*
this);
70 if (this->state_.has_value()) {
71 auto state = *this->state_;
72 if (!this->parent_->traits.supports_state(
state)) {
73 ESP_LOGW(TAG,
" State %s is not supported by this device!",
lock_state_to_string(*this->state_));
100 ESP_LOGW(TAG,
"'%s' - Unrecognized state %s", this->parent_->get_name().c_str(), state.c_str());
LockCall & set_state(LockState state)
Set the state of the lock device.
bool next(T value)
Feeds the next item in the series to the deduplicator and returns whether this is a duplicate...
LockState state
The current reported state of the lock.
const char * lock_state_to_string(LockState state)
const optional< LockState > & get_state() const
CallbackManager< void()> state_callback_
LockCall make_call()
Make a lock device control call, this is used to control the lock device, see the LockCall descriptio...
virtual void control(const LockCall &call)=0
Control the lock device, this is a virtual method that each lock integration must implement...
void add_on_state_callback(std::function< void()> &&callback)
Set callback for state changes.
This class is used to encode all control actions on a lock device.
Deduplicator< LockState > publish_dedup_
void lock()
Turn this lock on.
constexpr const char * c_str() const
virtual void open_latch()
Perform the open latch action with hardware.
void open()
Open (unlatch) this lock.
Implementation of SPI Controller mode.
void unlock()
Turn this lock off.
LockState
Enum for all states a lock can be in.
bool get_supports_open() const
const StringRef & get_name() const
void publish_state(LockState state)
Publish a state to the front-end from the back-end.
bool str_equals_case_insensitive(const std::string &a, const std::string &b)
Compare strings for equality in case-insensitive manner.