ESPHome 2025.5.0
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 {
12namespace hydreon_rgxx {
13
14enum RGModel {
15 RG9 = 1,
16 RG15 = 2,
17};
18
23
24#ifdef HYDREON_RGXX_NUM_SENSORS
25static const uint8_t NUM_SENSORS = HYDREON_RGXX_NUM_SENSORS;
26#else
27static 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; }
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;
86 bool disable_led_ = false;
87
88 // bit field showing which sensors we have received data for
90};
91
96
97} // namespace hydreon_rgxx
98} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
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 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:57
Resolution resolution
Definition msa3xx.h:1
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7