ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
hydreon_rgxx.h
Go to the documentation of this file.
1#pragma once
2
7#ifdef USE_BINARY_SENSOR
9#endif
12
13namespace esphome::hydreon_rgxx {
14
15enum RGModel {
16 RG9 = 1,
17 RG15 = 2,
18};
19
24
25#ifdef HYDREON_RGXX_NUM_SENSORS
26static const uint8_t NUM_SENSORS = HYDREON_RGXX_NUM_SENSORS;
27#else
28static const uint8_t NUM_SENSORS = 1;
29#endif
30
31#ifndef HYDREON_RGXX_PROTOCOL_LIST
32#define HYDREON_RGXX_PROTOCOL_LIST(F, SEP) F("")
33#endif
34
35#define HYDREON_RGXX_IGNORE_LIST(F, SEP) F("Emitters") SEP F("Event") SEP F("Reset")
36
38 public:
39 void set_sensor(sensor::Sensor *sensor, int index) { this->sensors_[index] = sensor; }
40#ifdef USE_BINARY_SENSOR
44#endif
45 void set_model(RGModel model) { model_ = model; }
48
50 void update() override;
52 void loop() override;
54 void setup() override;
55 void dump_config() override;
56
57 void set_disable_led(bool disable_led) { this->disable_led_ = disable_led; }
58
59 protected:
61 void process_line_(StringRef line);
62 void schedule_reboot_();
64
65 sensor::Sensor *sensors_[NUM_SENSORS] = {nullptr};
66#ifdef USE_BINARY_SENSOR
70#endif
71
72 int16_t boot_count_ = 0;
73 int16_t no_response_count_ = 0;
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;
85
86 // bit field showing which sensors we have received data for
88};
89
94
95} // namespace esphome::hydreon_rgxx
Collects bytes into NUL terminated lines of up to N - 1 characters; IGNORE_CHAR bytes are skipped and...
Definition line_reader.h:15
This class simplifies creating components that periodically check a state.
Definition component.h:519
StringRef is a reference to a string owned by something else.
Definition string_ref.h:31
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)
binary_sensor::BinarySensor * lens_bad_sensor_
void set_lens_bad_sensor(binary_sensor::BinarySensor *sensor)
void set_sensor(sensor::Sensor *sensor, int index)
void process_line_(StringRef line)
line is NUL terminated
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)
void set_em_sat_sensor(binary_sensor::BinarySensor *sensor)
Base-class for all sensors.
Definition sensor.h:47
Resolution resolution
Definition msa3xx.h:1