ESPHome 2025.5.0
Loading...
Searching...
No Matches
resistance_sensor.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome {
7namespace resistance {
8
13
15 public:
16 void set_sensor(Sensor *sensor) { sensor_ = sensor; }
17 void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
18 void set_resistor(float resistor) { resistor_ = resistor; }
19 void set_reference_voltage(float reference_voltage) { reference_voltage_ = reference_voltage; }
20
21 void setup() override {
22 this->sensor_->add_on_state_callback([this](float value) { this->process_(value); });
23 if (this->sensor_->has_state())
24 this->process_(this->sensor_->state);
25 }
26 void dump_config() override;
27 float get_setup_priority() const override { return setup_priority::DATA; }
28
29 protected:
30 void process_(float value);
33 float resistor_;
35};
36
37} // namespace resistance
38} // namespace esphome
void set_configuration(ResistanceConfiguration configuration)
void set_reference_voltage(float reference_voltage)
Base-class for all sensors.
Definition sensor.h:57
void add_on_state_callback(std::function< void(float)> &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition sensor.cpp:52
bool has_state() const
Return whether this sensor has gotten a full state (that passed through all filters) yet.
Definition sensor.cpp:97
float state
This member variable stores the last state that has passed through all filters.
Definition sensor.h:131
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