15#define LOG_LOCK(prefix, type, obj) \
16 if ((obj) != nullptr) { \
17 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
18 if (!(obj)->get_icon().empty()) { \
19 ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
21 if ((obj)->traits.get_assumed_state()) { \
22 ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
Helper class to deduplicate items in a series of values.
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.
optional< LockState > state_
Base class for all locks.
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_
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.
CallbackManager< void()> state_callback_
LockState state
The current reported state of the lock.
void unlock()
Turn this lock off.
void open()
Open (unlatch) this lock.
bool get_requires_code() const
bool supports_state(LockState state) const
std::set< LockState > supported_states_
std::set< LockState > get_supported_states() const
void set_assumed_state(bool assumed_state)
bool get_assumed_state() const
void set_supported_states(std::set< LockState > states)
void set_requires_code(bool requires_code)
bool get_supports_open() const
void set_supports_open(bool supports_open)
void add_supported_state(LockState state)
LockState
Enum for all states a lock can be in.
const char * lock_state_to_string(LockState state)
Providing packet encoding functions for exchanging data with a remote host.