ESPHome  2022.8.0
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 
19 #ifdef HYDREON_RGXX_NUM_SENSORS
20 static const uint8_t NUM_SENSORS = HYDREON_RGXX_NUM_SENSORS;
21 #else
22 static const uint8_t NUM_SENSORS = 1;
23 #endif
24 
25 #ifndef HYDREON_RGXX_PROTOCOL_LIST
26 #define HYDREON_RGXX_PROTOCOL_LIST(F, SEP) F("")
27 #endif
28 
30  public:
31  void set_sensor(sensor::Sensor *sensor, int index) { this->sensors_[index] = sensor; }
32 #ifdef USE_BINARY_SENSOR
34 #endif
35  void set_model(RGModel model) { model_ = model; }
36 
38  void update() override;
40  void loop() override;
42  void setup() override;
43  void dump_config() override;
44 
45  float get_setup_priority() const override;
46 
47  protected:
48  void process_line_();
49  void schedule_reboot_();
50  bool buffer_starts_with_(const std::string &prefix);
51  bool buffer_starts_with_(const char *prefix);
52  bool sensor_missing_();
53 
54  sensor::Sensor *sensors_[NUM_SENSORS] = {nullptr};
55 #ifdef USE_BINARY_SENSOR
57 #endif
58 
59  int16_t boot_count_ = 0;
60  int16_t no_response_count_ = 0;
61  std::string buffer_;
63  int sw_version_ = 0;
64  bool too_cold_ = false;
65 
66  // bit field showing which sensors we have received data for
68 };
69 
71  public:
73 };
74 
75 } // namespace hydreon_rgxx
76 } // namespace esphome
binary_sensor::BinarySensor * too_cold_sensor_
Definition: hydreon_rgxx.h:56
HydreonRGxxBinaryComponent(HydreonRGxxComponent *parent)
Definition: hydreon_rgxx.h:72
void set_too_cold_sensor(binary_sensor::BinarySensor *sensor)
Definition: hydreon_rgxx.h:33
void setup() override
Setup the sensor and test for a connection.
This class simplifies creating components that periodically check a state.
Definition: component.h:266
void schedule_reboot_()
Communication with the sensor is asynchronous.
void set_sensor(sensor::Sensor *sensor, int index)
Definition: hydreon_rgxx.h:31
sensor::Sensor * sensors_[NUM_SENSORS]
Definition: hydreon_rgxx.h:54
Definition: a4988.cpp:4
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:26
void loop() override
Read data once available.
bool buffer_starts_with_(const std::string &prefix)
Base-class for all sensors.
Definition: sensor.h:48
void update() override
Schedule data readings.