ESPHome 2025.5.0
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 {
6namespace emc2101 {
7
8static const char *const TAG = "EMC2101.sensor";
9
11
13 ESP_LOGCONFIG(TAG, "Emc2101 sensor:");
14 LOG_SENSOR(" ", "Internal temperature", this->internal_temperature_sensor_);
15 LOG_SENSOR(" ", "External temperature", this->external_temperature_sensor_);
16 LOG_SENSOR(" ", "Speed", this->speed_sensor_);
17 LOG_SENSOR(" ", "Duty cycle", this->duty_cycle_sensor_);
18}
19
21 if (this->internal_temperature_sensor_ != nullptr) {
22 float internal_temperature = this->parent_->get_internal_temperature();
23 this->internal_temperature_sensor_->publish_state(internal_temperature);
24 }
25
26 if (this->external_temperature_sensor_ != nullptr) {
27 float external_temperature = this->parent_->get_external_temperature();
28 this->external_temperature_sensor_->publish_state(external_temperature);
29 }
30
31 if (this->speed_sensor_ != nullptr) {
32 float speed = this->parent_->get_speed();
33 this->speed_sensor_->publish_state(speed);
34 }
35
36 if (this->duty_cycle_sensor_ != nullptr) {
37 float duty_cycle = this->parent_->get_duty_cycle();
38 this->duty_cycle_sensor_->publish_state(duty_cycle * 100.0f);
39 }
40}
41
42} // namespace emc2101
43} // namespace esphome
float get_setup_priority() const override
Used by ESPHome framework.
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:119
float get_speed()
Gets the tachometer speed sensor reading.
Definition emc2101.cpp:154
float get_internal_temperature()
Gets the internal temperature sensor reading.
Definition emc2101.cpp:129
float get_external_temperature()
Gets the external temperature sensor reading.
Definition emc2101.cpp:139
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:39
int speed
Definition fan.h:1
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7