ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
aqi
aqi_sensor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/sensor/sensor.h
"
5
#include "
aqi_calculator_factory.h
"
6
7
namespace
esphome::aqi
{
8
9
class
AQISensor
final :
public
sensor::Sensor
,
public
Component
{
10
SUB_SENSOR(pm_2_5)
11
SUB_SENSOR(pm_10_0)
12
13
public
:
14
void
setup
()
override
;
15
void
dump_config()
override
;
16
17
void
set_aqi_calculation_type(
AQICalculatorType
type
) { this->
aqi_calc_type_
=
type
; }
18
void
set_extended_range(
bool
extended_range) { this->
extended_range_
= extended_range; }
19
20
protected
:
21
void
calculate_aqi_
();
22
23
AQICalculatorType
aqi_calc_type_
{
AQI_TYPE
};
24
bool
extended_range_
{
false
};
25
AQICalculatorFactory
aqi_calculator_factory_
;
26
27
float
pm_2_5_value_
{NAN};
28
float
pm_10_0_value_
{NAN};
29
};
30
31
}
// namespace esphome::aqi
aqi_calculator_factory.h
esphome::Component
Definition
component.h:147
esphome::Component::setup
virtual void setup()
Where the component's initialization should happen.
Definition
component.cpp:84
esphome::aqi::AQICalculatorFactory
Definition
aqi_calculator_factory.h:10
esphome::aqi::AQISensor
Definition
aqi_sensor.h:9
esphome::aqi::AQISensor::aqi_calc_type_
AQICalculatorType aqi_calc_type_
Definition
aqi_sensor.h:23
esphome::aqi::AQISensor::extended_range_
bool extended_range_
Definition
aqi_sensor.h:24
esphome::aqi::AQISensor::pm_2_5_value_
float pm_2_5_value_
Definition
aqi_sensor.h:27
esphome::aqi::AQISensor::pm_10_0_value_
float pm_10_0_value_
Definition
aqi_sensor.h:28
esphome::aqi::AQISensor::aqi_calculator_factory_
AQICalculatorFactory aqi_calculator_factory_
Definition
aqi_sensor.h:25
esphome::aqi::AQISensor::calculate_aqi_
void calculate_aqi_()
Definition
aqi_sensor.cpp:41
esphome::sensor::Sensor
Base-class for all sensors.
Definition
sensor.h:48
component.h
type
uint8_t type
Definition
e131_packet.cpp:21
esphome::aqi
Definition
abstract_aqi_calculator.h:5
esphome::aqi::AQICalculatorType
AQICalculatorType
Definition
aqi_calculator_factory.h:8
esphome::aqi::AQI_TYPE
@ AQI_TYPE
Definition
aqi_calculator_factory.h:8
sensor.h
Generated by
1.12.0