ESPHome 2025.5.0
Loading...
Searching...
No Matches
mhz19.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome {
9namespace mhz19 {
10
12
14 public:
15 float get_setup_priority() const override;
16
17 void setup() override;
18 void update() override;
19 void dump_config() override;
20
21 void calibrate_zero();
22 void abc_enable();
23 void abc_disable();
24
25 void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
26 void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; }
27 void set_abc_enabled(bool abc_enabled) { abc_boot_logic_ = abc_enabled ? MHZ19_ABC_ENABLED : MHZ19_ABC_DISABLED; }
28 void set_warmup_seconds(uint32_t seconds) { warmup_seconds_ = seconds; }
29
30 protected:
31 bool mhz19_write_command_(const uint8_t *command, uint8_t *response);
32
37};
38
39template<typename... Ts> class MHZ19CalibrateZeroAction : public Action<Ts...> {
40 public:
42
43 void play(Ts... x) override { this->mhz19_->calibrate_zero(); }
44
45 protected:
47};
48
49template<typename... Ts> class MHZ19ABCEnableAction : public Action<Ts...> {
50 public:
52
53 void play(Ts... x) override { this->mhz19_->abc_enable(); }
54
55 protected:
57};
58
59template<typename... Ts> class MHZ19ABCDisableAction : public Action<Ts...> {
60 public:
62
63 void play(Ts... x) override { this->mhz19_->abc_disable(); }
64
65 protected:
67};
68
69} // namespace mhz19
70} // namespace esphome
This class simplifies creating components that periodically check a state.
Definition component.h:301
MHZ19ABCDisableAction(MHZ19Component *mhz19)
Definition mhz19.h:61
void play(Ts... x) override
Definition mhz19.h:63
MHZ19ABCEnableAction(MHZ19Component *mhz19)
Definition mhz19.h:51
void play(Ts... x) override
Definition mhz19.h:53
void play(Ts... x) override
Definition mhz19.h:43
MHZ19CalibrateZeroAction(MHZ19Component *mhz19)
Definition mhz19.h:41
void set_abc_enabled(bool abc_enabled)
Definition mhz19.h:27
void dump_config() override
Definition mhz19.cpp:103
float get_setup_priority() const override
Definition mhz19.cpp:102
sensor::Sensor * temperature_sensor_
Definition mhz19.h:33
sensor::Sensor * co2_sensor_
Definition mhz19.h:34
bool mhz19_write_command_(const uint8_t *command, uint8_t *response)
Definition mhz19.cpp:89
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition mhz19.h:25
MHZ19ABCLogic abc_boot_logic_
Definition mhz19.h:35
void set_warmup_seconds(uint32_t seconds)
Definition mhz19.h:28
void set_co2_sensor(sensor::Sensor *co2_sensor)
Definition mhz19.h:26
Base-class for all sensors.
Definition sensor.h:57
@ MHZ19_ABC_DISABLED
Definition mhz19.h:11
@ MHZ19_ABC_ENABLED
Definition mhz19.h:11
@ MHZ19_ABC_NONE
Definition mhz19.h:11
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5