ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
hydreon_rgxx.h
Go to the documentation of this file.
1#pragma once
2
6#ifdef USE_BINARY_SENSOR
8#endif
10
11namespace esphome::hydreon_rgxx {
12
13enum RGModel {
14 RG9 = 1,
15 RG15 = 2,
16};
17
22
23#ifdef HYDREON_RGXX_NUM_SENSORS
24static const uint8_t NUM_SENSORS = HYDREON_RGXX_NUM_SENSORS;
25#else
26static const uint8_t NUM_SENSORS = 1;
27#endif
28
29#ifndef HYDREON_RGXX_PROTOCOL_LIST
30#define HYDREON_RGXX_PROTOCOL_LIST(F, SEP) F("")
31#endif
32
33#define HYDREON_RGXX_IGNORE_LIST(F, SEP) F("Emitters") SEP F("Event") SEP F("Reset")
34
36 public:
37 void set_sensor(sensor::Sensor *sensor, int index) { this->sensors_[index] = sensor; }
38#ifdef USE_BINARY_SENSOR
42#endif
43 void set_model(RGModel model) { model_ = model; }
46
48 void update() override;
50 void loop() override;
52 void setup() override;
53 void dump_config() override;
54
55 void set_disable_led(bool disable_led) { this->disable_led_ = disable_led; }
56
57 protected:
58 void process_line_();
59 void schedule_reboot_();
60 bool buffer_starts_with_(const std::string &prefix);
61 bool buffer_starts_with_(const char *prefix);
63
64 sensor::Sensor *sensors_[NUM_SENSORS] = {nullptr};
65#ifdef USE_BINARY_SENSOR
69#endif
70
71 int16_t boot_count_ = 0;
72 int16_t no_response_count_ = 0;
73 std::string buffer_;
74
77
78 int sw_version_ = 0;
79 bool too_cold_ = false;
80 bool lens_bad_ = false;
81 bool em_sat_ = false;
83 bool disable_led_ = false;
84
85 // bit field showing which sensors we have received data for
87};
88
93
94} // namespace esphome::hydreon_rgxx
This class simplifies creating components that periodically check a state.
Definition component.h:585
Base class for all binary_sensor-type classes.
HydreonRGxxBinaryComponent(HydreonRGxxComponent *parent)
void update() override
Schedule data readings.
void setup() override
Setup the sensor and test for a connection.
binary_sensor::BinarySensor * em_sat_sensor_
void set_resolution(RG15Resolution resolution)
bool buffer_starts_with_(const char *prefix)
binary_sensor::BinarySensor * lens_bad_sensor_
void set_lens_bad_sensor(binary_sensor::BinarySensor *sensor)
void set_sensor(sensor::Sensor *sensor, int index)
void schedule_reboot_()
Communication with the sensor is asynchronous.
binary_sensor::BinarySensor * too_cold_sensor_
void loop() override
Read data once available.
sensor::Sensor * sensors_[NUM_SENSORS]
void set_too_cold_sensor(binary_sensor::BinarySensor *sensor)
bool buffer_starts_with_(const std::string &prefix)
void set_em_sat_sensor(binary_sensor::BinarySensor *sensor)
Base-class for all sensors.
Definition sensor.h:47
Resolution resolution
Definition msa3xx.h:1