ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
resistance_sensor.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::resistance {
7
12
14 public:
15 void set_sensor(Sensor *sensor) { sensor_ = sensor; }
16 void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; }
17 void set_resistor(float resistor) { resistor_ = resistor; }
18 void set_reference_voltage(float reference_voltage) { reference_voltage_ = reference_voltage; }
19
20 void setup() override {
21 this->sensor_->add_on_state_callback([this](float value) { this->process_(value); });
22 if (this->sensor_->has_state())
23 this->process_(this->sensor_->state);
24 }
25 void dump_config() override;
26
27 protected:
28 void process_(float value);
31 float resistor_;
33};
34
35} // namespace esphome::resistance
bool has_state() const
void set_configuration(ResistanceConfiguration configuration)
void set_reference_voltage(float reference_voltage)
Base-class for all sensors.
Definition sensor.h:47
void add_on_state_callback(F &&callback)
Add a callback that will be called every time a filtered value arrives.
Definition sensor.h:119
float state
This member variable stores the last state that has passed through all filters.
Definition sensor.h:138