mirror of
https://github.com/esphome/esphome.git
synced 2026-09-14 16:48:40 +00:00
Merge remote-tracking branch 'origin/lock-trigger-trampoline' into integration
This commit is contained in:
@@ -7,7 +7,7 @@ namespace copy {
|
||||
static const char *const TAG = "copy.lock";
|
||||
|
||||
void CopyLock::setup() {
|
||||
source_->add_on_state_callback([this]() { this->publish_state(source_->state); });
|
||||
source_->add_on_state_callback([this](lock::LockState state) { this->publish_state(state); });
|
||||
|
||||
traits.set_assumed_state(source_->traits.get_assumed_state());
|
||||
traits.set_requires_code(source_->traits.get_requires_code());
|
||||
|
||||
@@ -84,8 +84,8 @@ def lock_schema(
|
||||
@setup_entity("lock")
|
||||
async def _setup_lock_core(var, config):
|
||||
for conf_key, state_enum in (
|
||||
(CONF_ON_LOCK, "lock::LockState::LOCK_STATE_LOCKED"),
|
||||
(CONF_ON_UNLOCK, "lock::LockState::LOCK_STATE_UNLOCKED"),
|
||||
(CONF_ON_LOCK, LockState.LOCK_STATE_LOCKED),
|
||||
(CONF_ON_UNLOCK, LockState.LOCK_STATE_UNLOCKED),
|
||||
):
|
||||
for conf in config.get(conf_key, []):
|
||||
await automation.build_callback_automation(
|
||||
@@ -93,7 +93,7 @@ async def _setup_lock_core(var, config):
|
||||
"add_on_state_callback",
|
||||
[],
|
||||
conf,
|
||||
forwarder=LockStateForwarder.template(cg.RawExpression(state_enum)),
|
||||
forwarder=LockStateForwarder.template(state_enum),
|
||||
)
|
||||
|
||||
if mqtt_id := config.get(CONF_MQTT_ID):
|
||||
|
||||
@@ -148,7 +148,7 @@ class Lock : public EntityBase {
|
||||
|
||||
/** Set callback for state changes.
|
||||
*
|
||||
* @param callback The void(bool) callback.
|
||||
* @param callback The void(LockState) callback.
|
||||
*/
|
||||
template<typename F> void add_on_state_callback(F &&callback) {
|
||||
this->state_callback_.add(std::forward<F>(callback));
|
||||
|
||||
Reference in New Issue
Block a user