mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 10:38:27 +02:00
Store source package in Component for debugging (#2070)
This commit is contained in:
@@ -130,6 +130,17 @@ class Component {
|
||||
|
||||
bool has_overridden_loop() const;
|
||||
|
||||
/** Set where this component was loaded from for some debug messages.
|
||||
*
|
||||
* This is set by the ESPHome core, and should not be called manually.
|
||||
*/
|
||||
void set_component_source(const char *source) { component_source_ = source; }
|
||||
/** Get the integration where this component was declared as a string.
|
||||
*
|
||||
* Returns "<unknown>" if source not set
|
||||
*/
|
||||
const char *get_component_source() const;
|
||||
|
||||
protected:
|
||||
virtual void call_loop();
|
||||
virtual void call_setup();
|
||||
@@ -201,6 +212,7 @@ class Component {
|
||||
|
||||
uint32_t component_state_{0x0000}; ///< State of this component.
|
||||
float setup_priority_override_{NAN};
|
||||
const char *component_source_ = nullptr;
|
||||
};
|
||||
|
||||
/** This class simplifies creating components that periodically check a state.
|
||||
@@ -276,4 +288,14 @@ class Nameable {
|
||||
bool disabled_by_default_{false};
|
||||
};
|
||||
|
||||
class WarnIfComponentBlockingGuard {
|
||||
public:
|
||||
WarnIfComponentBlockingGuard(Component *component);
|
||||
~WarnIfComponentBlockingGuard();
|
||||
|
||||
protected:
|
||||
uint32_t started_;
|
||||
Component *component_;
|
||||
};
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user