mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Introduce call_dump_config() indirection (#2325)
This commit is contained in:
parent
2d7f8b3bdf
commit
1e8e471dec
5 changed files with 15 additions and 2 deletions
|
@ -186,6 +186,12 @@ void MQTTComponent::call_loop() {
|
|||
this->schedule_resend_state();
|
||||
}
|
||||
}
|
||||
void MQTTComponent::call_dump_config() {
|
||||
if (this->is_internal())
|
||||
return;
|
||||
|
||||
this->dump_config();
|
||||
}
|
||||
void MQTTComponent::schedule_resend_state() { this->resend_state_ = true; }
|
||||
std::string MQTTComponent::unique_id() { return ""; }
|
||||
bool MQTTComponent::is_connected_() const { return global_mqtt_client->is_connected(); }
|
||||
|
|
|
@ -62,6 +62,8 @@ class MQTTComponent : public Component {
|
|||
|
||||
void call_loop() override;
|
||||
|
||||
void call_dump_config() override;
|
||||
|
||||
/// Send discovery info the Home Assistant, override this.
|
||||
virtual void send_discovery(JsonObject &root, SendDiscoveryConfig &config) = 0;
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ void Application::loop() {
|
|||
#endif
|
||||
}
|
||||
|
||||
this->components_[this->dump_config_at_]->dump_config();
|
||||
this->components_[this->dump_config_at_]->call_dump_config();
|
||||
this->dump_config_at_++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,9 @@ bool Component::cancel_timeout(const std::string &name) { // NOLINT
|
|||
}
|
||||
|
||||
void Component::call_loop() { this->loop(); }
|
||||
|
||||
void Component::call_setup() { this->setup(); }
|
||||
void Component::call_dump_config() { this->dump_config(); }
|
||||
|
||||
uint32_t Component::get_component_state() const { return this->component_state_; }
|
||||
void Component::call() {
|
||||
uint32_t state = this->component_state_ & COMPONENT_STATE_MASK;
|
||||
|
|
|
@ -148,8 +148,12 @@ class Component {
|
|||
const char *get_component_source() const;
|
||||
|
||||
protected:
|
||||
friend class Application;
|
||||
|
||||
virtual void call_loop();
|
||||
virtual void call_setup();
|
||||
virtual void call_dump_config();
|
||||
|
||||
/** Set an interval function with a unique name. Empty name means no cancelling possible.
|
||||
*
|
||||
* This will call f every interval ms. Can be cancelled via CancelInterval().
|
||||
|
|
Loading…
Reference in a new issue