11static const char *
const TAG =
"mqtt.lock";
19 if (strcasecmp(payload.c_str(),
"LOCK") == 0) {
21 }
else if (strcasecmp(payload.c_str(),
"UNLOCK") == 0) {
23 }
else if (strcasecmp(payload.c_str(),
"OPEN") == 0) {
26 ESP_LOGW(TAG,
"'%s': Received unknown status payload: %s", this->
friendly_name_().c_str(), payload.c_str());
34 LOG_MQTT_COMPONENT(
true,
true);
42 root[MQTT_OPTIMISTIC] =
true;
45 root[MQTT_PAYLOAD_OPEN] =
"OPEN";
50#ifdef USE_STORE_LOG_STR_IN_FLASH
51 char buf[LOCK_STATE_STR_SIZE];
53 buf[
sizeof(buf) - 1] =
'\0';
ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") void defer(const std voi defer)(const char *name, std::function< void()> &&f)
Defer a callback to the next loop() call.
void status_momentary_warning(const char *name, uint32_t length=5000)
Set warning status flag and automatically clear it after a timeout.
const StringRef & get_name() const
constexpr const char * c_str() const
Base class for all locks.
void lock()
Turn this lock on.
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.
void open()
Open (unlatch) this lock.
bool get_assumed_state() const
bool get_supports_open() const
bool publish(const std::string &topic, const std::string &payload)
Send a MQTT message.
std::string get_state_topic_() const
Get the MQTT topic that new states will be shared to.
std::string friendly_name_() const
Get the friendly name of this MQTT component.
std::string get_command_topic_() const
Get the MQTT topic for listening to commands.
void subscribe(const std::string &topic, mqtt_callback_t callback, uint8_t qos=0)
Subscribe to a MQTT topic.
MQTTLockComponent(lock::Lock *a_lock)
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
void dump_config() override
bool send_initial_state() override
const LogString * lock_state_to_string(LockState state)
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
Simple Helper struct used for Home Assistant MQTT send_discovery().