ESPHome  2024.12.2
hydreon_rgxx.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/defines.h"
6 #ifdef USE_BINARY_SENSOR
8 #endif
10 
11 namespace esphome {
12 namespace hydreon_rgxx {
13 
14 enum RGModel {
15  RG9 = 1,
16  RG15 = 2,
17 };
18 
20  FORCE_LOW = 1,
22 };
23 
24 #ifdef HYDREON_RGXX_NUM_SENSORS
25 static const uint8_t NUM_SENSORS = HYDREON_RGXX_NUM_SENSORS;
26 #else
27 static const uint8_t NUM_SENSORS = 1;
28 #endif
29 
30 #ifndef HYDREON_RGXX_PROTOCOL_LIST
31 #define HYDREON_RGXX_PROTOCOL_LIST(F, SEP) F("")
32 #endif
33 
34 #define HYDREON_RGXX_IGNORE_LIST(F, SEP) F("Emitters") SEP F("Event") SEP F("Reset")
35 
37  public:
38  void set_sensor(sensor::Sensor *sensor, int index) { this->sensors_[index] = sensor; }
39 #ifdef USE_BINARY_SENSOR
43 #endif
44  void set_model(RGModel model) { model_ = model; }
45  void set_resolution(RG15Resolution resolution) { resolution_ = resolution; }
47 
49  void update() override;
51  void loop() override;
53  void setup() override;
54  void dump_config() override;
55 
56  float get_setup_priority() const override;
57 
58  void set_disable_led(bool disable_led) { this->disable_led_ = disable_led; }
59 
60  protected:
61  void process_line_();
62  void schedule_reboot_();
63  bool buffer_starts_with_(const std::string &prefix);
64  bool buffer_starts_with_(const char *prefix);
66 
67  sensor::Sensor *sensors_[NUM_SENSORS] = {nullptr};
68 #ifdef USE_BINARY_SENSOR
72 #endif
73 
74  int16_t boot_count_ = 0;
75  int16_t no_response_count_ = 0;
76  std::string buffer_;
77 
80 
81  int sw_version_ = 0;
82  bool too_cold_ = false;
83  bool lens_bad_ = false;
84  bool em_sat_ = false;
85  bool request_temperature_ = false;
86  bool disable_led_ = false;
87 
88  // bit field showing which sensors we have received data for
90 };
91 
93  public:
95 };
96 
97 } // namespace hydreon_rgxx
98 } // namespace esphome
void set_resolution(RG15Resolution resolution)
Definition: hydreon_rgxx.h:45
binary_sensor::BinarySensor * too_cold_sensor_
Definition: hydreon_rgxx.h:69
binary_sensor::BinarySensor * lens_bad_sensor_
Definition: hydreon_rgxx.h:70
HydreonRGxxBinaryComponent(HydreonRGxxComponent *parent)
Definition: hydreon_rgxx.h:94
void set_too_cold_sensor(binary_sensor::BinarySensor *sensor)
Definition: hydreon_rgxx.h:40
void setup() override
Setup the sensor and test for a connection.
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void schedule_reboot_()
Communication with the sensor is asynchronous.
void set_lens_bad_sensor(binary_sensor::BinarySensor *sensor)
Definition: hydreon_rgxx.h:41
void set_sensor(sensor::Sensor *sensor, int index)
Definition: hydreon_rgxx.h:38
void set_em_sat_sensor(binary_sensor::BinarySensor *sensor)
Definition: hydreon_rgxx.h:42
sensor::Sensor * sensors_[NUM_SENSORS]
Definition: hydreon_rgxx.h:67
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
binary_sensor::BinarySensor * em_sat_sensor_
Definition: hydreon_rgxx.h:71
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
void loop() override
Read data once available.
bool buffer_starts_with_(const std::string &prefix)
Base-class for all sensors.
Definition: sensor.h:57
void update() override
Schedule data readings.
esphome::sensor::Sensor * sensor
Definition: statsd.h:38