ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
automation.cpp
Go to the documentation of this file.
2
3#ifdef USE_OPENTHREAD
4
5#include "automation.h"
6#include "esphome/core/log.h"
7
9
10static const char *const TAG = "openthread.automation";
11
13 ESP_LOGW(TAG, "OpenThread action has no effect on FTD devices (MTD only)");
14}
15
17 if (this->parent_->is_ready()) {
19 if (auto *instance = lock.get_instance(); instance != nullptr) {
20 this->apply_locked(instance);
21 }
22 } else {
23 ESP_LOGW(TAG, "Failed to acquire lock in action");
24 }
25 } else {
26 // Action may trigger early before setup, e.g. due to enabled "restore mode".
27 // Trying to acquire lock would fail!
28 //
29 // But default component values already have been overwritten.
30 // It is sufficient to let component apply those later during setup.
31 ESP_LOGD(TAG, "Not (yet) ready to apply");
32 }
33}
34
35} // namespace esphome::openthread
36
37#endif
static InstanceLock try_acquire(int delay)
virtual void apply_locked(otInstance *instance)=0
Handler to implement in subclass for applying action parts that need lock.
void lock_and_apply_()
Fetch OT lock and then call apply_locked.
static constexpr uint32_t LOCK_ACQUIRE_TIMEOUT_MS
Timeout (ms) for acquiring OT lock.
Definition automation.h:34
void warn_ftd_no_op_()
Log a warning that this action has no effect on FTD devices.
SemaphoreHandle_t lock