8static constexpr uint32_t CALCULATE_DEFER_ID = 0;
11 if (this->pm_2_5_sensor_ !=
nullptr) {
12 this->pm_2_5_sensor_->add_on_state_callback([
this](
float value) {
18 if (this->pm_10_0_sensor_ !=
nullptr) {
19 this->pm_10_0_sensor_->add_on_state_callback([
this](
float value) {
26void AQISensor::dump_config() {
27 ESP_LOGCONFIG(TAG,
"AQI Sensor:");
28 ESP_LOGCONFIG(TAG,
" Calculation Type: %s",
30 ESP_LOGCONFIG(TAG,
" Extended Range: %s",
31 this->
extended_range_ ? LOG_STR_LITERAL(
"enabled") : LOG_STR_LITERAL(
"disabled"));
32 if (this->pm_2_5_sensor_ !=
nullptr) {
33 ESP_LOGCONFIG(TAG,
" PM2.5 Sensor: '%s'", LOG_STR_ARG(this->pm_2_5_sensor_->get_log_name()));
35 if (this->pm_10_0_sensor_ !=
nullptr) {
36 ESP_LOGCONFIG(TAG,
" PM10 Sensor: '%s'", LOG_STR_ARG(this->pm_10_0_sensor_->get_log_name()));
38 LOG_SENSOR(
" ",
"AQI",
this);
47 if (calculator ==
nullptr) {
48 ESP_LOGW(TAG,
"Unknown AQI calculator type");
virtual void setup()
Where the component's initialization should happen.
void defer(const char *name, std::function< void()> &&f)
Defer a callback to the next loop() call with a const char* name.
AbstractAQICalculator * get_calculator(AQICalculatorType type)
AQICalculatorType aqi_calc_type_
AQICalculatorFactory aqi_calculator_factory_
virtual uint16_t get_aqi(float pm2_5_value, float pm10_0_value, bool extended_range)=0
void publish_state(float state)
Publish a new state to the front-end.
ESPHOME_LOG_TAG(TAG, "aqi")