ESPHome  1.15.2
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::Component Class Reference

#include <component.h>

Inheritance diagram for esphome::Component:
esphome::a4988::A4988 esphome::ac_dimmer::AcDimmer esphome::ads1115::ADS1115Component esphome::api::APIServer esphome::as3935::AS3935Component esphome::bang_bang::BangBangClimate esphome::binary::BinaryFan esphome::binary_sensor::DelayedOffFilter esphome::binary_sensor::DelayedOnFilter esphome::binary_sensor::DelayedOnOffFilter esphome::binary_sensor::MultiClickTrigger esphome::binary_sensor_map::BinarySensorMap esphome::ble_presence::BLEPresenceDevice esphome::ble_rssi::BLERSSISensor esphome::ble_scanner::BLEScanner esphome::captive_portal::CaptivePortal esphome::climate_ir::ClimateIR esphome::custom::CustomBinarySensorConstructor esphome::custom::CustomSensorConstructor esphome::custom::CustomSwitchConstructor esphome::custom::CustomTextSensorConstructor esphome::debug::DebugComponent esphome::deep_sleep::DeepSleepComponent esphome::DelayAction< Ts > esphome::dfplayer::DFPlayer esphome::e131::E131Component esphome::endstop::EndstopCover esphome::esp32_ble_beacon::ESP32BLEBeacon esphome::esp32_ble_tracker::ESP32BLETracker esphome::esp32_camera::ESP32Camera esphome::esp32_dac::ESP32DAC esphome::esp32_touch::ESP32TouchComponent esphome::esp8266_pwm::ESP8266PWM esphome::ethernet::EthernetComponent esphome::fan::FanState esphome::ForCondition< Ts > esphome::globals::GlobalsComponent< T > esphome::gpio::GPIOBinaryOutput esphome::gpio::GPIOBinarySensor esphome::gpio::GPIOSwitch esphome::gps::GPS esphome::homeassistant::HomeassistantBinarySensor esphome::homeassistant::HomeassistantSensor esphome::homeassistant::HomeassistantTextSensor esphome::http_request::HttpRequestComponent esphome::i2c::I2CComponent esphome::integration::IntegrationSensor esphome::ledc::LEDCOutput esphome::light::AddressableLight esphome::light::LightState esphome::logger::Logger esphome::LoopTrigger esphome::mcp23008::MCP23008 esphome::mcp23016::MCP23016 esphome::mcp23017::MCP23017 esphome::mcp3008::MCP3008 esphome::modbus::Modbus esphome::mpr121::MPR121Component esphome::mqtt::MQTTClientComponent esphome::mqtt::MQTTComponent esphome::mqtt::MQTTMessageTrigger esphome::mqtt_subscribe::MQTTSubscribeSensor esphome::mqtt_subscribe::MQTTSubscribeTextSensor esphome::my9231::MY9231OutputComponent esphome::ntc::NTC esphome::ota::OTAComponent esphome::output::OutputSwitch esphome::pca9685::PCA9685Output esphome::pcf8574::PCF8574Component esphome::pid::PIDClimate esphome::pid::PIDClimateSensor esphome::pmsx003::PMSX003Component esphome::PollingComponent esphome::power_supply::PowerSupply esphome::prometheus::PrometheusHandler esphome::rdm6300::RDM6300Component esphome::remote_base::RawTrigger esphome::remote_base::RemoteReceiverBinarySensorBase esphome::resistance::ResistanceSensor esphome::restart::RestartSwitch esphome::rf_bridge::RFBridgeComponent esphome::rotary_encoder::RotaryEncoderSensor esphome::rtttl::Rtttl esphome::ruuvitag::RuuviTag esphome::script::QueueingScript esphome::script::ScriptWaitAction< Ts > esphome::sds011::SDS011Component esphome::sensor::DebounceFilter esphome::sensor::HeartbeatFilter esphome::sensor::ValueRangeTrigger esphome::servo::Servo esphome::shutdown::ShutdownSwitch esphome::ShutdownTrigger esphome::slow_pwm::SlowPWMOutput esphome::sm16716::SM16716 esphome::sn74hc595::SN74HC595Component esphome::speed::SpeedFan esphome::spi::SPIComponent esphome::StartupTrigger esphome::status::StatusBinarySensor esphome::status_led::StatusLED esphome::sx1509::SX1509Component esphome::sx1509::SX1509FloatOutputChannel esphome::template_::TemplateBinarySensor esphome::template_::TemplateCover esphome::template_::TemplateSwitch esphome::thermostat::ThermostatClimate esphome::time::CronTrigger esphome::time::RealTimeClock esphome::time_based::TimeBasedCover esphome::tlc59208f::TLC59208FOutput esphome::tm1651::TM1651Display esphome::total_daily_energy::TotalDailyEnergy esphome::ttp229_bsf::TTP229BSFComponent esphome::ttp229_lsf::TTP229LSFComponent esphome::tuya::Tuya esphome::tuya::TuyaBinarySensor esphome::tuya::TuyaClimate esphome::tuya::TuyaFan esphome::tuya::TuyaLight esphome::tuya::TuyaSensor esphome::tuya::TuyaSwitch esphome::tx20::Tx20Component esphome::uart::UARTComponent esphome::uart::UARTSwitch esphome::uln2003::ULN2003 esphome::version::VersionTextSensor esphome::WaitUntilAction< Ts > esphome::web_server::WebServer esphome::web_server_base::WebServerBase esphome::wifi::WiFiComponent esphome::wifi_info::BSSIDWiFiInfo esphome::wifi_info::IPAddressWiFiInfo esphome::wifi_info::MacAddressWifiInfo esphome::wifi_info::SSIDWiFiInfo esphome::xiaomi_cgd1::XiaomiCGD1 esphome::xiaomi_cgg1::XiaomiCGG1 esphome::xiaomi_gcls002::XiaomiGCLS002 esphome::xiaomi_hhccjcy01::XiaomiHHCCJCY01 esphome::xiaomi_hhccpot002::XiaomiHHCCPOT002 esphome::xiaomi_jqjcy01ym::XiaomiJQJCY01YM esphome::xiaomi_lywsd02::XiaomiLYWSD02 esphome::xiaomi_lywsd03mmc::XiaomiLYWSD03MMC esphome::xiaomi_lywsdcgq::XiaomiLYWSDCGQ esphome::xiaomi_mjyd02yla::XiaomiMJYD02YLA esphome::xiaomi_mue4094rt::XiaomiMUE4094RT esphome::xiaomi_wx08zm::XiaomiWX08ZM esphome::yashima::YashimaClimate

Public Member Functions

virtual void setup ()
 Where the component's initialization should happen. More...
 
virtual void loop ()
 This method will be called repeatedly. More...
 
virtual void dump_config ()
 
virtual float get_setup_priority () const
 priority of setup(). More...
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
bool is_failed ()
 
virtual bool can_proceed ()
 
bool status_has_warning ()
 
bool status_has_error ()
 
void status_set_warning ()
 
void status_set_error ()
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 

Protected Member Functions

virtual void call_loop ()
 
virtual void call_setup ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Protected Attributes

uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 

Detailed Description

Definition at line 56 of file component.h.

Member Function Documentation

◆ call()

void esphome::Component::call ( )

Definition at line 65 of file component.cpp.

◆ call_loop()

void esphome::Component::call_loop ( )
protectedvirtual

Reimplemented in esphome::mqtt::MQTTComponent.

Definition at line 61 of file component.cpp.

◆ call_setup()

void esphome::Component::call_setup ( )
protectedvirtual

◆ can_proceed()

bool esphome::Component::can_proceed ( )
virtual

◆ cancel_defer()

bool esphome::Component::cancel_defer ( const std::string &  name)
protected

Cancel a defer callback using the specified name, name must not be empty.

Definition at line 100 of file component.cpp.

◆ cancel_interval()

bool esphome::Component::cancel_interval ( const std::string &  name)
protected

Cancel an interval function.

Parameters
nameThe identifier for this interval function.
Returns
Whether an interval functions was deleted.

Definition at line 49 of file component.cpp.

◆ cancel_timeout()

bool esphome::Component::cancel_timeout ( const std::string &  name)
protected

Cancel a timeout function.

Parameters
nameThe identifier for this timeout function.
Returns
Whether a timeout functions was deleted.

Definition at line 57 of file component.cpp.

◆ defer() [1/2]

void esphome::Component::defer ( const std::string &  name,
std::function< void()> &&  f 
)
protected

Defer a callback to the next loop() call.

If name is specified and a defer() object with the same name exists, the old one is first removed.

Parameters
nameThe name of the defer function.
fThe callback.

Definition at line 103 of file component.cpp.

◆ defer() [2/2]

void esphome::Component::defer ( std::function< void()> &&  f)
protected

Defer a callback to the next loop() call.

Definition at line 97 of file component.cpp.

◆ dump_config()

void esphome::Component::dump_config ( )
virtual

Reimplemented in esphome::remote_base::RemoteReceiverBinarySensorBase, esphome::mqtt::MQTTMessageTrigger, esphome::waveshare_epaper::WaveshareEPaper7P5InV2, esphome::waveshare_epaper::WaveshareEPaper7P5In, esphome::fastled_base::FastLEDLightOutput, esphome::waveshare_epaper::WaveshareEPaper5P8In, esphome::wifi::WiFiComponent, esphome::light::LightState, esphome::mqtt::MQTTClientComponent, esphome::waveshare_epaper::WaveshareEPaper4P2In, esphome::esp32_ble_tracker::ESP32BLETracker, esphome::waveshare_epaper::WaveshareEPaper2P9InB, esphome::st7789v::ST7789V, esphome::i2c::I2CComponent, esphome::waveshare_epaper::WaveshareEPaper2P7In, esphome::bme680::BME680Component, esphome::dfplayer::DFPlayer, esphome::waveshare_epaper::WaveshareEPaperTypeA, esphome::bme280::BME280Component, esphome::max31856::MAX31856Sensor, esphome::esp32_camera::ESP32Camera, esphome::mpr121::MPR121Component, esphome::zyaura::ZyAuraSensor, esphome::spi::SPIComponent, esphome::tsl2561::TSL2561Sensor, esphome::web_server::WebServer, esphome::bmp280::BMP280Component, esphome::wifi_info::MacAddressWifiInfo, esphome::uart::UARTComponent, esphome::pulse_counter::PulseCounterSensor, esphome::tuya::Tuya, esphome::deep_sleep::DeepSleepComponent, esphome::rotary_encoder::RotaryEncoderSensor, esphome::wifi_info::BSSIDWiFiInfo, esphome::as3935::AS3935Component, esphome::ble_presence::BLEPresenceDevice, esphome::ota::OTAComponent, esphome::ble_rssi::BLERSSISensor, esphome::ruuvitag::RuuviTag, esphome::ac_dimmer::AcDimmer, esphome::logger::Logger, esphome::dht::DHT, esphome::servo::Servo, esphome::pca9685::PCA9685Output, esphome::tcs34725::TCS34725Component, esphome::tlc59208f::TLC59208FOutput, esphome::sx1509::SX1509Component, esphome::hmc5883l::HMC5883LComponent, esphome::pcd8544::PCD8544, esphome::sim800l::Sim800LComponent, esphome::ads1115::ADS1115Component, esphome::rf_bridge::RFBridgeComponent, esphome::wifi_info::SSIDWiFiInfo, esphome::esp32_ble_beacon::ESP32BLEBeacon, esphome::bh1750::BH1750Sensor, esphome::esp32_touch::ESP32TouchComponent, esphome::max31865::MAX31865Sensor, esphome::mqtt::MQTTSensorComponent, esphome::tx20::Tx20Component, esphome::climate_ir::ClimateIR, esphome::template_::TemplateCover, esphome::ethernet::EthernetComponent, esphome::pulse_width::PulseWidthSensor, esphome::lcd_gpio::GPIOLCDDisplay, esphome::pcf8574::PCF8574Component, esphome::api::APIServer, esphome::qmc5883l::QMC5883LComponent, esphome::ade7953::ADE7953, esphome::ble_scanner::BLEScanner, esphome::sun::SunTextSensor, esphome::max7219digit::MAX7219Component, esphome::mqtt::MQTTCoverComponent, esphome::integration::IntegrationSensor, esphome::pid::PIDClimateSensor, esphome::power_supply::PowerSupply, esphome::sps30::SPS30Component, esphome::gpio::GPIOSwitch, esphome::http_request::HttpRequestComponent, esphome::max7219::MAX7219Component, esphome::thermostat::ThermostatClimate, esphome::duty_cycle::DutyCycleSensor, esphome::ledc::LEDCOutput, esphome::resistance::ResistanceSensor, esphome::binary_sensor_map::BinarySensorMap, esphome::hm3301::HM3301Component, esphome::uln2003::ULN2003, esphome::vl53l0x::VL53L0XSensor, esphome::bang_bang::BangBangClimate, esphome::ccs811::CCS811Component, esphome::tm1637::TM1637Display, esphome::ttp229_bsf::TTP229BSFComponent, esphome::adc::ADCSensor, esphome::esp8266_pwm::ESP8266PWM, esphome::hx711::HX711Sensor, esphome::mqtt::MQTTBinarySensorComponent, esphome::my9231::MY9231OutputComponent, esphome::pzemac::PZEMAC, esphome::sgp30::SGP30Component, esphome::ttp229_lsf::TTP229LSFComponent, esphome::xiaomi_mjyd02yla::XiaomiMJYD02YLA, esphome::captive_portal::CaptivePortal, esphome::pzemdc::PZEMDC, esphome::ultrasonic::UltrasonicSensorComponent, esphome::xiaomi_wx08zm::XiaomiWX08ZM, esphome::mqtt::MQTTJSONLightComponent, esphome::mqtt::MQTTTextSensor, esphome::pmsx003::PMSX003Component, esphome::pzem004t::PZEM004T, esphome::scd30::SCD30Component, esphome::sm16716::SM16716, esphome::wifi_info::IPAddressWiFiInfo, esphome::xiaomi_mue4094rt::XiaomiMUE4094RT, esphome::dallas::DallasComponent, esphome::mcp3008::MCP3008, esphome::mqtt::MQTTSwitchComponent, esphome::pn532::PN532, esphome::rtttl::Rtttl, esphome::sds011::SDS011Component, esphome::as3935_spi::SPIAS3935Component, esphome::bmp085::BMP085Component, esphome::cse7766::CSE7766Component, esphome::esp32_dac::ESP32DAC, esphome::gpio::GPIOBinaryOutput, esphome::mhz19::MHZ19Component, esphome::pid::PIDClimate, esphome::shtcx::SHTCXComponent, esphome::sun::SunSensor, esphome::xiaomi_cgd1::XiaomiCGD1, esphome::xiaomi_cgg1::XiaomiCGG1, esphome::xiaomi_gcls002::XiaomiGCLS002, esphome::xiaomi_hhccjcy01::XiaomiHHCCJCY01, esphome::xiaomi_hhccpot002::XiaomiHHCCPOT002, esphome::xiaomi_jqjcy01ym::XiaomiJQJCY01YM, esphome::xiaomi_lywsd02::XiaomiLYWSD02, esphome::xiaomi_lywsd03mmc::XiaomiLYWSD03MMC, esphome::xiaomi_lywsdcgq::XiaomiLYWSDCGQ, esphome::max31855::MAX31855Sensor, esphome::sntp::SNTPComponent, esphome::ssd1306_spi::SPISSD1306, esphome::ssd1325_spi::SPISSD1325, esphome::ssd1351_spi::SPISSD1351, esphome::template_::TemplateTextSensor, esphome::tm1651::TM1651Display, esphome::custom::CustomBinarySensorConstructor, esphome::custom::CustomTextSensorConstructor, esphome::hdc1080::HDC1080Component, esphome::htu21d::HTU21DComponent, esphome::modbus::Modbus, esphome::sht3xd::SHT3XDComponent, esphome::slow_pwm::SlowPWMOutput, esphome::a4988::A4988, esphome::binary::BinaryFan, esphome::ct_clamp::CTClampSensor, esphome::gpio::GPIOBinarySensor, esphome::hlw8012::HLW8012Component, esphome::max6675::MAX6675Sensor, esphome::ntc::NTC, esphome::output::OutputSwitch, esphome::senseair::SenseAirComponent, esphome::speed::SpeedFan, esphome::sx1509::SX1509FloatOutputChannel, esphome::total_daily_energy::TotalDailyEnergy, esphome::atm90e32::ATM90E32Component, esphome::custom::CustomSensorConstructor, esphome::custom::CustomSwitchConstructor, esphome::endstop::EndstopCover, esphome::mqtt_subscribe::MQTTSubscribeSensor, esphome::mqtt_subscribe::MQTTSubscribeTextSensor, esphome::sn74hc595::SN74HC595Component, esphome::template_::TemplateSensor, esphome::template_::TemplateSwitch, esphome::aht10::AHT10Component, esphome::apds9960::APDS9960, esphome::as3935_i2c::I2CAS3935Component, esphome::lcd_pcf8574::PCF8574LCDDisplay, esphome::status::StatusBinarySensor, esphome::status_led::StatusLED, esphome::sts3x::STS3XComponent, esphome::template_::TemplateBinarySensor, esphome::time_based::TimeBasedCover, esphome::uart::UARTSwitch, esphome::wifi_signal::WiFiSignalSensor, esphome::am2320::AM2320Component, esphome::dht12::DHT12Component, esphome::esp32_hall::ESP32HallSensor, esphome::homeassistant::HomeassistantBinarySensor, esphome::homeassistant::HomeassistantSensor, esphome::homeassistant::HomeassistantTime, esphome::ina219::INA219Component, esphome::ina226::INA226Component, esphome::ina3221::INA3221Component, esphome::mpu6050::MPU6050Component, esphome::ms5611::MS5611Component, esphome::ssd1306_i2c::I2CSSD1306, esphome::tmp117::TMP117Component, esphome::tuya::TuyaBinarySensor, esphome::tuya::TuyaClimate, esphome::tuya::TuyaFan, esphome::tuya::TuyaLight, esphome::tuya::TuyaSensor, esphome::tuya::TuyaSwitch, esphome::version::VersionTextSensor, esphome::debug::DebugComponent, esphome::homeassistant::HomeassistantTextSensor, esphome::uptime::UptimeSensor, esphome::restart::RestartSwitch, and esphome::shutdown::ShutdownSwitch.

Definition at line 134 of file component.cpp.

◆ get_actual_setup_priority()

float esphome::Component::get_actual_setup_priority ( ) const

Definition at line 135 of file component.cpp.

◆ get_component_state()

uint32_t esphome::Component::get_component_state ( ) const

Definition at line 64 of file component.cpp.

◆ get_loop_priority()

float esphome::Component::get_loop_priority ( ) const
virtual

priority of loop().

higher -> executed earlier

Defaults to 0.

Returns
The loop priority of this component

Reimplemented in esphome::wifi::WiFiComponent, esphome::deep_sleep::DeepSleepComponent, and esphome::status_led::StatusLED.

Definition at line 37 of file component.cpp.

◆ get_setup_priority()

float esphome::Component::get_setup_priority ( ) const
virtual

priority of setup().

higher -> executed earlier

Defaults to 0.

Returns
The setup priority of this component

Reimplemented in esphome::nextion::Nextion, esphome::mqtt::MQTTMessageTrigger, esphome::WaitUntilAction< Ts >, esphome::sensor::HeartbeatFilter, esphome::fastled_base::FastLEDLightOutput, esphome::sensor::DebounceFilter, esphome::wifi::WiFiComponent, esphome::light::LightState, esphome::mqtt::MQTTClientComponent, esphome::spi::SPIComponent, esphome::script::ScriptWaitAction< Ts >, esphome::i2c::I2CComponent, esphome::st7789v::ST7789V, esphome::DelayAction< Ts >, esphome::bme680::BME680Component, esphome::LoopTrigger, esphome::fan::FanState, esphome::binary_sensor::MultiClickTrigger, esphome::neopixelbus::NeoPixelBusLightOutputBase< T_METHOD, T_COLOR_FEATURE >, esphome::StartupTrigger, esphome::mqtt::MQTTComponent, esphome::uart::UARTComponent, esphome::bme280::BME280Component, esphome::max31856::MAX31856Sensor, esphome::esp32_camera::ESP32Camera, esphome::mpr121::MPR121Component, esphome::zyaura::ZyAuraSensor, esphome::web_server::WebServer, esphome::tsl2561::TSL2561Sensor, esphome::bmp280::BMP280Component, esphome::ForCondition< Ts >, esphome::deep_sleep::DeepSleepComponent, esphome::rotary_encoder::RotaryEncoderSensor, esphome::pulse_counter::PulseCounterSensor, esphome::tuya::Tuya, esphome::binary_sensor::DelayedOffFilter, esphome::as3935::AS3935Component, esphome::ble_presence::BLEPresenceDevice, esphome::ota::OTAComponent, esphome::wifi_info::BSSIDWiFiInfo, esphome::ble_rssi::BLERSSISensor, esphome::logger::Logger, esphome::mcp23017::MCP23017, esphome::ruuvitag::RuuviTag, esphome::sensor::ValueRangeTrigger, esphome::dht::DHT, esphome::binary_sensor::DelayedOnFilter, esphome::servo::Servo, esphome::pca9685::PCA9685Output, esphome::tlc59208f::TLC59208FOutput, esphome::mcp23016::MCP23016, esphome::sx1509::SX1509Component, esphome::hmc5883l::HMC5883LComponent, esphome::mcp23008::MCP23008, esphome::tcs34725::TCS34725Component, esphome::ads1115::ADS1115Component, esphome::bh1750::BH1750Sensor, esphome::esp32_ble_beacon::ESP32BLEBeacon, esphome::esp32_touch::ESP32TouchComponent, esphome::max31865::MAX31865Sensor, esphome::ssd1306_base::SSD1306, esphome::template_::TemplateCover, esphome::tx20::Tx20Component, esphome::wifi_info::SSIDWiFiInfo, esphome::binary_sensor_map::BinarySensorMap, esphome::ethernet::EthernetComponent, esphome::pcd8544::PCD8544, esphome::pulse_width::PulseWidthSensor, esphome::ssd1325_base::SSD1325, esphome::binary_sensor::DelayedOnOffFilter, esphome::max7219digit::MAX7219Component, esphome::qmc5883l::QMC5883LComponent, esphome::web_server_base::WebServerBase, esphome::ble_scanner::BLEScanner, esphome::e131::E131Component, esphome::max7219::MAX7219Component, esphome::pcf8574::PCF8574Component, esphome::ssd1351_base::SSD1351, esphome::api::APIServer, esphome::power_supply::PowerSupply, esphome::globals::GlobalsComponent< T >, esphome::gps::GPS, esphome::integration::IntegrationSensor, esphome::prometheus::PrometheusHandler, esphome::sps30::SPS30Component, esphome::tm1637::TM1637Display, esphome::http_request::HttpRequestComponent, esphome::ledc::LEDCOutput, esphome::captive_portal::CaptivePortal, esphome::resistance::ResistanceSensor, esphome::time::CronTrigger, esphome::ccs811::CCS811Component, esphome::hm3301::HM3301Component, esphome::uln2003::ULN2003, esphome::ultrasonic::UltrasonicSensorComponent, esphome::vl53l0x::VL53L0XSensor, esphome::adc::ADCSensor, esphome::duty_cycle::DutyCycleSensor, esphome::esp8266_pwm::ESP8266PWM, esphome::my9231::MY9231OutputComponent, esphome::sntp::SNTPComponent, esphome::template_::TemplateSwitch, esphome::ttp229_bsf::TTP229BSFComponent, esphome::gpio::GPIOSwitch, esphome::hx711::HX711Sensor, esphome::sgp30::SGP30Component, esphome::ttp229_lsf::TTP229LSFComponent, esphome::xiaomi_mjyd02yla::XiaomiMJYD02YLA, esphome::lcd_base::LCDDisplay, esphome::pn532::PN532, esphome::sds011::SDS011Component, esphome::sm16716::SM16716, esphome::xiaomi_wx08zm::XiaomiWX08ZM, esphome::scd30::SCD30Component, esphome::xiaomi_mue4094rt::XiaomiMUE4094RT, esphome::bmp085::BMP085Component, esphome::dallas::DallasComponent, esphome::esp32_dac::ESP32DAC, esphome::hdc1080::HDC1080Component, esphome::htu21d::HTU21DComponent, esphome::mcp3008::MCP3008, esphome::modbus::Modbus, esphome::rdm6300::RDM6300Component, esphome::gpio::GPIOBinaryOutput, esphome::pmsx003::PMSX003Component, esphome::shtcx::SHTCXComponent, esphome::xiaomi_cgd1::XiaomiCGD1, esphome::xiaomi_cgg1::XiaomiCGG1, esphome::xiaomi_gcls002::XiaomiGCLS002, esphome::xiaomi_hhccjcy01::XiaomiHHCCJCY01, esphome::xiaomi_hhccpot002::XiaomiHHCCPOT002, esphome::xiaomi_jqjcy01ym::XiaomiJQJCY01YM, esphome::xiaomi_lywsd02::XiaomiLYWSD02, esphome::xiaomi_lywsd03mmc::XiaomiLYWSD03MMC, esphome::xiaomi_lywsdcgq::XiaomiLYWSDCGQ, esphome::max31855::MAX31855Sensor, esphome::slow_pwm::SlowPWMOutput, esphome::wifi_info::IPAddressWiFiInfo, esphome::a4988::A4988, esphome::gpio::GPIOBinarySensor, esphome::sht3xd::SHT3XDComponent, esphome::binary::BinaryFan, esphome::cse7766::CSE7766Component, esphome::ct_clamp::CTClampSensor, esphome::hlw8012::HLW8012Component, esphome::max6675::MAX6675Sensor, esphome::mpu6050::MPU6050Component, esphome::ntc::NTC, esphome::speed::SpeedFan, esphome::sx1509::SX1509FloatOutputChannel, esphome::template_::TemplateSensor, esphome::total_daily_energy::TotalDailyEnergy, esphome::wifi_signal::WiFiSignalSensor, esphome::atm90e32::ATM90E32Component, esphome::endstop::EndstopCover, esphome::mqtt_subscribe::MQTTSubscribeSensor, esphome::mqtt_subscribe::MQTTSubscribeTextSensor, esphome::status::StatusBinarySensor, esphome::status_led::StatusLED, esphome::template_::TemplateBinarySensor, esphome::template_::TemplateTextSensor, esphome::waveshare_epaper::WaveshareEPaper, esphome::aht10::AHT10Component, esphome::apds9960::APDS9960, esphome::homeassistant::HomeassistantTime, esphome::ina3221::INA3221Component, esphome::mhz19::MHZ19Component, esphome::output::OutputSwitch, esphome::sts3x::STS3XComponent, esphome::time_based::TimeBasedCover, esphome::am2320::AM2320Component, esphome::dht12::DHT12Component, esphome::homeassistant::HomeassistantBinarySensor, esphome::homeassistant::HomeassistantSensor, esphome::ina219::INA219Component, esphome::ina226::INA226Component, esphome::ms5611::MS5611Component, esphome::sn74hc595::SN74HC595Component, esphome::tmp117::TMP117Component, esphome::uptime::UptimeSensor, esphome::version::VersionTextSensor, esphome::interval::IntervalTrigger, esphome::senseair::SenseAirComponent, and esphome::debug::DebugComponent.

Definition at line 39 of file component.cpp.

◆ has_overridden_loop()

bool esphome::Component::has_overridden_loop ( ) const

Definition at line 142 of file component.cpp.

◆ is_failed()

bool esphome::Component::is_failed ( )

Definition at line 112 of file component.cpp.

◆ loop()

void esphome::Component::loop ( )
virtual

This method will be called repeatedly.

Analogous to Arduino's loop(). setup() is guaranteed to be called before this. Defaults to doing nothing.

Reimplemented in esphome::nextion::Nextion, esphome::WaitUntilAction< Ts >, esphome::fastled_base::FastLEDLightOutput, esphome::wifi::WiFiComponent, esphome::light::LightState, esphome::mqtt::MQTTClientComponent, esphome::esp32_ble_tracker::ESP32BLETracker, esphome::st7789v::ST7789V, esphome::script::ScriptWaitAction< Ts >, esphome::LoopTrigger, esphome::neopixelbus::NeoPixelBusLightOutputBase< T_METHOD, T_COLOR_FEATURE >, esphome::mpr121::MPR121Component, esphome::esp32_camera::ESP32Camera, esphome::ForCondition< Ts >, esphome::deep_sleep::DeepSleepComponent, esphome::rotary_encoder::RotaryEncoderSensor, esphome::tuya::Tuya, esphome::as3935::AS3935Component, esphome::ota::OTAComponent, esphome::script::QueueingScript, esphome::partition::PartitionLightOutput, esphome::wifi_info::BSSIDWiFiInfo, esphome::pca9685::PCA9685Output, esphome::tlc59208f::TLC59208FOutput, esphome::sx1509::SX1509Component, esphome::sim800l::Sim800LComponent, esphome::tx20::Tx20Component, esphome::esp32_touch::ESP32TouchComponent, esphome::rf_bridge::RFBridgeComponent, esphome::binary_sensor_map::BinarySensorMap, esphome::template_::TemplateCover, esphome::ethernet::EthernetComponent, esphome::api::APIServer, esphome::e131::E131Component, esphome::globals::GlobalsComponent< T >, esphome::gps::GPS, esphome::vl53l0x::VL53L0XSensor, esphome::wifi_info::SSIDWiFiInfo, esphome::dfplayer::DFPlayer, esphome::max7219digit::MAX7219Component, esphome::my9231::MY9231OutputComponent, esphome::sntp::SNTPComponent, esphome::sm16716::SM16716, esphome::time::CronTrigger, esphome::ttp229_bsf::TTP229BSFComponent, esphome::pn532::PN532, esphome::ttp229_lsf::TTP229LSFComponent, esphome::uln2003::ULN2003, esphome::captive_portal::CaptivePortal, esphome::rtttl::Rtttl, esphome::slow_pwm::SlowPWMOutput, esphome::template_::TemplateSwitch, esphome::sds011::SDS011Component, esphome::total_daily_energy::TotalDailyEnergy, esphome::gpio::GPIOBinarySensor, esphome::pmsx003::PMSX003Component, esphome::a4988::A4988, esphome::apds9960::APDS9960, esphome::pzem004t::PZEM004T, esphome::cse7766::CSE7766Component, esphome::rdm6300::RDM6300Component, esphome::binary::BinaryFan, esphome::ct_clamp::CTClampSensor, esphome::modbus::Modbus, esphome::speed::SpeedFan, esphome::status_led::StatusLED, esphome::endstop::EndstopCover, esphome::template_::TemplateBinarySensor, esphome::time_based::TimeBasedCover, esphome::wifi_info::IPAddressWiFiInfo, esphome::status::StatusBinarySensor, and esphome::debug::DebugComponent.

Definition at line 43 of file component.cpp.

◆ mark_failed()

void esphome::Component::mark_failed ( )
virtual

Mark this component as failed.

Any future timeouts/intervals/setup/loop will no longer be called.

This might be useful if a component wants to indicate that a connection to its peripheral failed. For example, i2c based components can check if the remote device is responding and otherwise mark the component as failed. Eventually this will also enable smart status LEDs.

Definition at line 91 of file component.cpp.

◆ on_safe_shutdown()

virtual void esphome::Component::on_safe_shutdown ( )
inlinevirtual

Reimplemented in esphome::ota::OTAComponent, and esphome::waveshare_epaper::WaveshareEPaper.

Definition at line 97 of file component.h.

◆ on_shutdown()

virtual void esphome::Component::on_shutdown ( )
inlinevirtual

◆ set_interval() [1/2]

void esphome::Component::set_interval ( const std::string &  name,
uint32_t  interval,
std::function< void()> &&  f 
)
protected

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(). Similar to javascript's setInterval().

IMPORTANT: Do not rely on this having correct timing. This is only called from loop() and therefore can be significantly delay. If you need exact timing please use hardware timers.

Parameters
nameThe identifier for this interval function.
intervalThe interval in ms.
fThe function (or lambda) that should be called
See also
cancel_interval()

Definition at line 45 of file component.cpp.

◆ set_interval() [2/2]

void esphome::Component::set_interval ( uint32_t  interval,
std::function< void()> &&  f 
)
protected

Definition at line 109 of file component.cpp.

◆ set_setup_priority()

void esphome::Component::set_setup_priority ( float  priority)

Definition at line 140 of file component.cpp.

◆ set_timeout() [1/2]

void esphome::Component::set_timeout ( uint32_t  timeout,
std::function< void()> &&  f 
)
protected

Definition at line 106 of file component.cpp.

◆ set_timeout() [2/2]

void esphome::Component::set_timeout ( const std::string &  name,
uint32_t  timeout,
std::function< void()> &&  f 
)
protected

Set a timeout function with a unique name.

Similar to javascript's setTimeout(). Empty name means no cancelling possible.

IMPORTANT: Do not rely on this having correct timing. This is only called from loop() and therefore can be significantly delay. If you need exact timing please use hardware timers.

Parameters
nameThe identifier for this timeout function.
timeoutThe timeout in ms.
fThe function (or lambda) that should be called
See also
cancel_timeout()

Definition at line 53 of file component.cpp.

◆ setup()

void esphome::Component::setup ( )
virtual

Where the component's initialization should happen.

Analogous to Arduino's setup(). This method is guaranteed to only be called once. Defaults to doing nothing.

Reimplemented in esphome::nextion::Nextion, esphome::mqtt::MQTTMessageTrigger, esphome::sensor::HeartbeatFilter, esphome::fastled_base::FastLEDLightOutput, esphome::wifi::WiFiComponent, esphome::light::LightState, esphome::mqtt::MQTTClientComponent, esphome::esp32_ble_tracker::ESP32BLETracker, esphome::st7789v::ST7789V, esphome::i2c::I2CComponent, esphome::bme680::BME680Component, esphome::fan::FanState, esphome::binary_sensor::MultiClickTrigger, esphome::StartupTrigger, esphome::bme280::BME280Component, esphome::max31856::MAX31856Sensor, esphome::neopixelbus::NeoPixelBusLightOutputBase< T_METHOD, T_COLOR_FEATURE >, esphome::esp32_camera::ESP32Camera, esphome::mpr121::MPR121Component, esphome::zyaura::ZyAuraSensor, esphome::tsl2561::TSL2561Sensor, esphome::bmp280::BMP280Component, esphome::spi::SPIComponent, esphome::web_server::WebServer, esphome::wifi_info::MacAddressWifiInfo, esphome::pid::PIDSimulator, esphome::uart::UARTComponent, esphome::tuya::Tuya, esphome::deep_sleep::DeepSleepComponent, esphome::pulse_counter::PulseCounterSensor, esphome::rotary_encoder::RotaryEncoderSensor, esphome::as3935::AS3935Component, esphome::ota::OTAComponent, esphome::mcp23017::MCP23017, esphome::pcd8544::PCD8544, esphome::ac_dimmer::AcDimmer, esphome::dht::DHT, esphome::pca9685::PCA9685Output, esphome::sensor::ValueRangeTrigger, esphome::tlc59208f::TLC59208FOutput, esphome::sx1509::SX1509Component, esphome::hmc5883l::HMC5883LComponent, esphome::tcs34725::TCS34725Component, esphome::ads1115::ADS1115Component, esphome::mcp23016::MCP23016, esphome::esp32_ble_beacon::ESP32BLEBeacon, esphome::mcp23008::MCP23008, esphome::bh1750::BH1750Sensor, esphome::esp32_touch::ESP32TouchComponent, esphome::max31865::MAX31865Sensor, esphome::tx20::Tx20Component, esphome::climate_ir::ClimateIR, esphome::mqtt::MQTTSensorComponent, esphome::mcp3008::MCP3008Sensor, esphome::pulse_width::PulseWidthSensor, esphome::servo::Servo, esphome::template_::TemplateCover, esphome::ethernet::EthernetComponent, esphome::qmc5883l::QMC5883LComponent, esphome::waveshare_epaper::WaveshareEPaper, esphome::e131::E131Component, esphome::api::APIServer, esphome::whirlpool::WhirlpoolClimate, esphome::integration::IntegrationSensor, esphome::mqtt::MQTTFanComponent, esphome::power_supply::PowerSupply, esphome::gpio::GPIOSwitch, esphome::max7219digit::MAX7219Component, esphome::sps30::SPS30Component, esphome::thermostat::ThermostatClimate, esphome::ledc::LEDCOutput, esphome::max7219::MAX7219Component, esphome::prometheus::PrometheusHandler, esphome::duty_cycle::DutyCycleSensor, esphome::hm3301::HM3301Component, esphome::pid::PIDClimateSensor, esphome::bang_bang::BangBangClimate, esphome::pcf8574::PCF8574Component, esphome::ssd1306_base::SSD1306, esphome::ttp229_bsf::TTP229BSFComponent, esphome::uln2003::ULN2003, esphome::vl53l0x::VL53L0XSensor, esphome::adc::ADCSensor, esphome::ade7953::ADE7953, esphome::esp8266_pwm::ESP8266PWM, esphome::hx711::HX711Sensor, esphome::lcd_base::LCDDisplay, esphome::my9231::MY9231OutputComponent, esphome::tm1637::TM1637Display, esphome::ttp229_lsf::TTP229LSFComponent, esphome::captive_portal::CaptivePortal, esphome::globals::GlobalsComponent< T >, esphome::mqtt::MQTTBinarySensorComponent, esphome::resistance::ResistanceSensor, esphome::sgp30::SGP30Component, esphome::ultrasonic::UltrasonicSensorComponent, esphome::ccs811::CCS811Component, esphome::mqtt::MQTTClimateComponent, esphome::ssd1325_base::SSD1325, esphome::dallas::DallasComponent, esphome::mcp3008::MCP3008, esphome::mqtt::MQTTJSONLightComponent, esphome::mqtt::MQTTSwitchComponent, esphome::mqtt::MQTTTextSensor, esphome::scd30::SCD30Component, esphome::sds011::SDS011Component, esphome::sm16716::SM16716, esphome::as3935_spi::SPIAS3935Component, esphome::bmp085::BMP085Component, esphome::esp32_dac::ESP32DAC, esphome::pid::PIDClimate, esphome::pn532::PN532, esphome::shtcx::SHTCXComponent, esphome::max31855::MAX31855Sensor, esphome::mhz19::MHZ19Component, esphome::mqtt::MQTTCoverComponent, esphome::sntp::SNTPComponent, esphome::ssd1351_base::SSD1351, esphome::tm1651::TM1651Display, esphome::gps::GPSTime, esphome::hdc1080::HDC1080Component, esphome::htu21d::HTU21DComponent, esphome::sht3xd::SHT3XDComponent, esphome::slow_pwm::SlowPWMOutput, esphome::ssd1306_spi::SPISSD1306, esphome::ssd1325_spi::SPISSD1325, esphome::ssd1351_spi::SPISSD1351, esphome::a4988::A4988, esphome::gpio::GPIOBinarySensor, esphome::hlw8012::HLW8012Component, esphome::max6675::MAX6675Sensor, esphome::ntc::NTC, esphome::sx1509::SX1509FloatOutputChannel, esphome::total_daily_energy::TotalDailyEnergy, esphome::yashima::YashimaClimate, esphome::atm90e32::ATM90E32Component, esphome::binary::BinaryFan, esphome::gpio::GPIOBinaryOutput, esphome::mqtt_subscribe::MQTTSubscribeSensor, esphome::mqtt_subscribe::MQTTSubscribeTextSensor, esphome::output::OutputSwitch, esphome::speed::SpeedFan, esphome::template_::TemplateSwitch, esphome::apds9960::APDS9960, esphome::ct_clamp::CTClampSensor, esphome::endstop::EndstopCover, esphome::homeassistant::HomeassistantTextSensor, esphome::lcd_pcf8574::PCF8574LCDDisplay, esphome::sn74hc595::SN74HC595Component, esphome::status::StatusBinarySensor, esphome::sts3x::STS3XComponent, esphome::aht10::AHT10Component, esphome::am2320::AM2320Component, esphome::dht12::DHT12Component, esphome::homeassistant::HomeassistantBinarySensor, esphome::homeassistant::HomeassistantSensor, esphome::homeassistant::HomeassistantTime, esphome::ina219::INA219Component, esphome::ina226::INA226Component, esphome::ina3221::INA3221Component, esphome::lcd_gpio::GPIOLCDDisplay, esphome::mpu6050::MPU6050Component, esphome::ms5611::MS5611Component, esphome::ssd1306_i2c::I2CSSD1306, esphome::time_based::TimeBasedCover, esphome::tmp117::TMP117Component, esphome::tuya::TuyaBinarySensor, esphome::tuya::TuyaClimate, esphome::tuya::TuyaFan, esphome::tuya::TuyaLight, esphome::tuya::TuyaSensor, esphome::tuya::TuyaSwitch, and esphome::version::VersionTextSensor.

Definition at line 41 of file component.cpp.

◆ status_clear_error()

void esphome::Component::status_clear_error ( )

Definition at line 125 of file component.cpp.

◆ status_clear_warning()

void esphome::Component::status_clear_warning ( )

Definition at line 124 of file component.cpp.

◆ status_has_error()

bool esphome::Component::status_has_error ( )

Definition at line 115 of file component.cpp.

◆ status_has_warning()

bool esphome::Component::status_has_warning ( )

Definition at line 114 of file component.cpp.

◆ status_momentary_error()

void esphome::Component::status_momentary_error ( const std::string &  name,
uint32_t  length = 5000 
)

Definition at line 130 of file component.cpp.

◆ status_momentary_warning()

void esphome::Component::status_momentary_warning ( const std::string &  name,
uint32_t  length = 5000 
)

Definition at line 126 of file component.cpp.

◆ status_set_error()

void esphome::Component::status_set_error ( )

Definition at line 120 of file component.cpp.

◆ status_set_warning()

void esphome::Component::status_set_warning ( )

Definition at line 116 of file component.cpp.

Field Documentation

◆ component_state_

uint32_t esphome::Component::component_state_ {0x0000}
protected

State of this component.

Definition at line 200 of file component.h.

◆ setup_priority_override_

float esphome::Component::setup_priority_override_ {NAN}
protected

Definition at line 201 of file component.h.


The documentation for this class was generated from the following files: