ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
emc2101_sensor.cpp
Go to the documentation of this file.
1#include "emc2101_sensor.h"
3#include "esphome/core/log.h"
4
5namespace esphome::emc2101 {
6
7static const char *const TAG = "EMC2101.sensor";
8
10 ESP_LOGCONFIG(TAG, "Emc2101 sensor:");
11 LOG_SENSOR(" ", "Internal temperature", this->internal_temperature_sensor_);
12 LOG_SENSOR(" ", "External temperature", this->external_temperature_sensor_);
13 LOG_SENSOR(" ", "Speed", this->speed_sensor_);
14 LOG_SENSOR(" ", "Duty cycle", this->duty_cycle_sensor_);
15}
16
18 if (this->internal_temperature_sensor_ != nullptr) {
19 float internal_temperature = this->parent_->get_internal_temperature();
20 this->internal_temperature_sensor_->publish_state(internal_temperature);
21 }
22
23 if (this->external_temperature_sensor_ != nullptr) {
24 float external_temperature = this->parent_->get_external_temperature();
25 this->external_temperature_sensor_->publish_state(external_temperature);
26 }
27
28 if (this->speed_sensor_ != nullptr) {
29 float speed = this->parent_->get_speed();
30 this->speed_sensor_->publish_state(speed);
31 }
32
33 if (this->duty_cycle_sensor_ != nullptr) {
34 float duty_cycle = this->parent_->get_duty_cycle();
35 this->duty_cycle_sensor_->publish_state(duty_cycle * 100.0f);
36 }
37}
38
39} // namespace esphome::emc2101
void update() override
Used by ESPHome framework.
void dump_config() override
Used by ESPHome framework.
sensor::Sensor * internal_temperature_sensor_
sensor::Sensor * external_temperature_sensor_
float get_duty_cycle()
Gets the Fan output duty cycle.
Definition emc2101.cpp:118
float get_speed()
Gets the tachometer speed sensor reading.
Definition emc2101.cpp:153
float get_internal_temperature()
Gets the internal temperature sensor reading.
Definition emc2101.cpp:128
float get_external_temperature()
Gets the external temperature sensor reading.
Definition emc2101.cpp:138
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68
int speed
Definition fan.h:3