8#include <initializer_list>
14#define LOG_LOCK(prefix, type, obj) \
15 if ((obj) != nullptr) { \
16 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
17 if (!(obj)->get_icon_ref().empty()) { \
18 ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon_ref().c_str()); \
20 if ((obj)->traits.get_assumed_state()) { \
21 ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
36static constexpr size_t LOCK_STATE_STR_SIZE = 10;
52 for (
auto state : states) {
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.
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 get_requires_code() const
bool supports_state(LockState state) const
void set_assumed_state(bool assumed_state)
bool get_assumed_state() const
void set_supported_states_mask(uint8_t mask)
void set_requires_code(bool requires_code)
bool get_supports_open() const
void set_supports_open(bool supports_open)
void set_supported_states(std::initializer_list< LockState > states)
void add_supported_state(LockState state)
uint8_t get_supported_states_mask() const
uint8_t supported_states_mask_
const LogString * lock_state_to_string(LockState state)
LockState
Enum for all states a lock can be in.