ESPHome  2022.6.3
senseair.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 namespace esphome {
9 namespace senseair {
10 
12  public:
13  float get_setup_priority() const override { return setup_priority::DATA; }
14  void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; }
15 
16  void update() override;
17  void dump_config() override;
18 
21  void abc_get_period();
22  void abc_enable();
23  void abc_disable();
24 
25  protected:
26  uint16_t senseair_checksum_(uint8_t *ptr, uint8_t length);
27  bool senseair_write_command_(const uint8_t *command, uint8_t *response, uint8_t response_length);
28 
30 };
31 
32 template<typename... Ts> class SenseAirBackgroundCalibrationAction : public Action<Ts...> {
33  public:
34  SenseAirBackgroundCalibrationAction(SenseAirComponent *senseair) : senseair_(senseair) {}
35 
36  void play(Ts... x) override { this->senseair_->background_calibration(); }
37 
38  protected:
40 };
41 
42 template<typename... Ts> class SenseAirBackgroundCalibrationResultAction : public Action<Ts...> {
43  public:
45 
46  void play(Ts... x) override { this->senseair_->background_calibration_result(); }
47 
48  protected:
50 };
51 
52 template<typename... Ts> class SenseAirABCEnableAction : public Action<Ts...> {
53  public:
54  SenseAirABCEnableAction(SenseAirComponent *senseair) : senseair_(senseair) {}
55 
56  void play(Ts... x) override { this->senseair_->abc_enable(); }
57 
58  protected:
60 };
61 
62 template<typename... Ts> class SenseAirABCDisableAction : public Action<Ts...> {
63  public:
64  SenseAirABCDisableAction(SenseAirComponent *senseair) : senseair_(senseair) {}
65 
66  void play(Ts... x) override { this->senseair_->abc_disable(); }
67 
68  protected:
70 };
71 
72 template<typename... Ts> class SenseAirABCGetPeriodAction : public Action<Ts...> {
73  public:
74  SenseAirABCGetPeriodAction(SenseAirComponent *senseair) : senseair_(senseair) {}
75 
76  void play(Ts... x) override { this->senseair_->abc_get_period(); }
77 
78  protected:
80 };
81 
82 } // namespace senseair
83 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:18
uint16_t senseair_checksum_(uint8_t *ptr, uint8_t length)
Definition: senseair.cpp:63
This class simplifies creating components that periodically check a state.
Definition: component.h:266
SenseAirBackgroundCalibrationAction(SenseAirComponent *senseair)
Definition: senseair.h:34
float get_setup_priority() const override
Definition: senseair.h:13
void set_co2_sensor(sensor::Sensor *co2_sensor)
Definition: senseair.h:14
bool senseair_write_command_(const uint8_t *command, uint8_t *response, uint8_t response_length)
Definition: senseair.cpp:143
SenseAirABCDisableAction(SenseAirComponent *senseair)
Definition: senseair.h:64
SenseAirBackgroundCalibrationResultAction(SenseAirComponent *senseair)
Definition: senseair.h:44
Definition: a4988.cpp:4
SenseAirABCEnableAction(SenseAirComponent *senseair)
Definition: senseair.h:54
Base-class for all sensors.
Definition: sensor.h:47
SenseAirABCGetPeriodAction(SenseAirComponent *senseair)
Definition: senseair.h:74