46 void play(
const Ts &...
x)
override {
47 auto ssid = this->ssid_.value(
x...);
48 auto password = this->password_.value(
x...);
53 char ssid_buf[SSID_BUFFER_SIZE];
71 if (this->save_.value(
x...)) {
81 global_wifi_component->disable();
82 global_wifi_component->save_wifi_sta(old_sta_.get_ssid(), old_sta_.get_password());
83 global_wifi_component->enable();
85 this->set_timeout(FALLBACK_TIMEOUT_ID, this->connection_timeout_.value(x...), [this]() {
86 this->connecting_ = false;
87 this->error_trigger_.trigger();
92 Trigger<> *get_connect_trigger() {
return &this->connect_trigger_; }
96 if (!this->connecting_)
100 this->cancel_timeout(CONNECT_TIMEOUT_ID);
101 this->cancel_timeout(FALLBACK_TIMEOUT_ID);
102 this->connecting_ =
false;
103 char ssid_buf[SSID_BUFFER_SIZE];
106 this->connect_trigger_.trigger();
109 this->error_trigger_.trigger();
118 bool connecting_{
false};
virtual void play(const Ts &...x)=0
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
Base class for all automation conditions.
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Inform the parent automation that the event has triggered.
bool check(const Ts &...x) override
StringRef get_ssid() const
void set_ssid(const std::string &ssid)
StringRef get_password() const
void set_password(const std::string &password)
void set_sta(const WiFiAP &ap)
void save_wifi_sta(const std::string &ssid, const std::string &password)
const char * wifi_ssid_to(std::span< char, SSID_BUFFER_SIZE > buffer)
Write SSID to buffer without heap allocation.
bool is_ap_active() const
void force_roam_check()
Force an immediate post-connect roaming check, bypassing the periodic interval and the per-connection...
bool is_connected() const
bool check(const Ts &...x) override
void play(const Ts &...x) override
void play(const Ts &...x) override
bool check(const Ts &...x) override
void play(const Ts &...x) override
WiFiComponent * global_wifi_component