1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-15 17:38:15 +00:00
esphome/esphome/components/analog_threshold/analog_threshold_binary_sensor.h
Adrián Panella 8cb9be7560
Analog threshold (#3190)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2022-02-18 09:14:10 +13:00

30 lines
823 B
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/binary_sensor/binary_sensor.h"
#include "esphome/components/sensor/sensor.h"
namespace esphome {
namespace analog_threshold {
class AnalogThresholdBinarySensor : public Component, public binary_sensor::BinarySensor {
public:
void dump_config() override;
void setup() override;
float get_setup_priority() const override { return setup_priority::DATA; }
void set_sensor(sensor::Sensor *analog_sensor);
void set_upper_threshold(float threshold) { this->upper_threshold_ = threshold; }
void set_lower_threshold(float threshold) { this->lower_threshold_ = threshold; }
protected:
sensor::Sensor *sensor_{nullptr};
float upper_threshold_;
float lower_threshold_;
};
} // namespace analog_threshold
} // namespace esphome