10 if (this->temperature_sensor_ !=
nullptr) {
11 this->temperature_sensor_->add_on_state_callback([
this](
float state) {
16 if (this->temperature_sensor_->has_state()) {
21 if (this->humidity_sensor_ !=
nullptr) {
22 this->humidity_sensor_->add_on_state_callback([
this](
float state) {
27 if (this->humidity_sensor_->has_state()) {
33void DewPointComponent::dump_config() {
34 LOG_SENSOR(
"",
"Dew Point",
this);
37 " Temperature: '%s'\n"
39 LOG_STR_ARG(this->temperature_sensor_->get_log_name()),
40 LOG_STR_ARG(this->humidity_sensor_->get_log_name()));
45void DewPointComponent::loop() {
51 ESP_LOGW(TAG,
"Temperature or humidity value is NaN, skipping calculation");
58 ESP_LOGW(TAG,
"Humidity value out of range (0-100): %.2f", this->
humidity_value_);
64 const float a{17.625f};
65 const float b{243.04f};
74 const float dew_point{(
b * alpha) / (a - alpha)};
79 ESP_LOGD(TAG,
"'%s' >> %.1f°C (T: %.1f°C, RH: %.1f%%)", LOG_STR_ARG(this->
get_log_name()), dew_point,