ESPHome  2024.11.0
absolute_humidity.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace absolute_humidity {
8 
14 };
15 
18  public:
19  AbsoluteHumidityComponent() = default;
20 
21  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; }
22  void set_humidity_sensor(sensor::Sensor *humidity_sensor) { this->humidity_sensor_ = humidity_sensor; }
23  void set_equation(SaturationVaporPressureEquation equation) { this->equation_ = equation; }
24 
25  void setup() override;
26  void dump_config() override;
27  float get_setup_priority() const override;
28  void loop() override;
29 
30  protected:
32  this->next_update_ = true;
33  this->temperature_ = state;
34  }
35  void humidity_callback_(float state) {
36  this->next_update_ = true;
37  this->humidity_ = state;
38  }
39 
44  static float es_buck(float temperature_c);
49  static float es_tetens(float temperature_c);
54  static float es_wobus(float temperature_c);
55 
63  static float vapor_density(float es, float hr, float ta);
64 
67 
68  bool next_update_{false};
69 
70  float temperature_{NAN};
71  float humidity_{NAN};
73 };
74 
75 } // namespace absolute_humidity
76 } // namespace esphome
static float vapor_density(float es, float hr, float ta)
Calculate vapor density (absolute humidity) in g/m³.
static float es_tetens(float temperature_c)
Tetens equation for saturation vapor pressure in kPa.
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
float state
This member variable stores the last state that has passed through all filters.
Definition: sensor.h:131
This class implements calculation of absolute humidity from temperature and relative humidity...
void set_equation(SaturationVaporPressureEquation equation)
void set_humidity_sensor(sensor::Sensor *humidity_sensor)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
static float es_wobus(float temperature_c)
Wobus equation for saturation vapor pressure in kPa.
Base-class for all sensors.
Definition: sensor.h:57
SaturationVaporPressureEquation
Enum listing all implemented saturation vapor pressure equations.
static float es_buck(float temperature_c)
Buck equation for saturation vapor pressure in kPa.