ESPHome 2025.10.0-dev
Loading...
Searching...
No Matches
ags10.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome {
9namespace ags10 {
10
12 public:
16 void set_tvoc(sensor::Sensor *tvoc) { this->tvoc_ = tvoc; }
17
21 void set_version(sensor::Sensor *version) { this->version_ = version; }
22
26 void set_resistance(sensor::Sensor *resistance) { this->resistance_ = resistance; }
27
28 void setup() override;
29
30 void update() override;
31
32 void dump_config() override;
33
39 bool new_i2c_address(uint8_t newaddress);
40
45
50
54 bool set_zero_point_with(uint16_t value);
55
56 protected:
61
66
71
82
87
92
97
101 template<size_t N> optional<std::array<uint8_t, N>> read_and_check_(uint8_t a_register);
102};
103
104template<typename... Ts> class AGS10NewI2cAddressAction : public Action<Ts...>, public Parented<AGS10Component> {
105 public:
106 TEMPLATABLE_VALUE(uint8_t, new_address)
107
108 void play(Ts... x) override { this->parent_->new_i2c_address(this->new_address_.value(x...)); }
109};
110
112 // Zero-point reset.
114 // Zero-point calibration with current resistance.
116 // Zero-point calibration with custom resistance.
118};
119
120template<typename... Ts> class AGS10SetZeroPointAction : public Action<Ts...>, public Parented<AGS10Component> {
121 public:
122 TEMPLATABLE_VALUE(uint16_t, value)
124
125 void play(Ts... x) override {
126 switch (this->mode_.value(x...)) {
127 case FACTORY_DEFAULT:
128 this->parent_->set_zero_point_with_factory_defaults();
129 break;
130 case CURRENT_VALUE:
131 this->parent_->set_zero_point_with_current_resistance();
132 break;
133 case CUSTOM_VALUE:
134 this->parent_->set_zero_point_with(this->value_.value(x...));
135 break;
136 }
137 }
138};
139} // namespace ags10
140} // namespace esphome
BedjetMode mode
BedJet operating mode.
virtual void play(Ts... x)=0
Helper class to easily give an object a parent of type T.
Definition helpers.h:697
This class simplifies creating components that periodically check a state.
Definition component.h:429
optional< std::array< uint8_t, N > > read_and_check_(uint8_t a_register)
Read, checks and returns data from the sensor.
Definition ags10.cpp:176
ErrorCode
Last operation error code.
Definition ags10.h:75
bool set_zero_point_with_factory_defaults()
Sets zero-point with factory defaults.
Definition ags10.cpp:106
optional< uint8_t > read_version_()
Reads and returns a firmware version of AGS10.
Definition ags10.cpp:158
void set_resistance(sensor::Sensor *resistance)
Sets resistance info sensor.
Definition ags10.h:26
enum esphome::ags10::AGS10Component::ErrorCode NONE
sensor::Sensor * tvoc_
TVOC.
Definition ags10.h:60
bool set_zero_point_with_current_resistance()
Sets zero-point with current sensor resistance.
Definition ags10.cpp:108
sensor::Sensor * resistance_
Resistance.
Definition ags10.h:70
void set_tvoc(sensor::Sensor *tvoc)
Sets TVOC sensor.
Definition ags10.h:16
void set_version(sensor::Sensor *version)
Sets version info sensor.
Definition ags10.h:21
optional< uint32_t > read_resistance_()
Reads and returns the resistance of AGS10.
Definition ags10.cpp:167
optional< uint32_t > read_tvoc_()
Reads and returns value of TVOC.
Definition ags10.cpp:131
sensor::Sensor * version_
Firmvare version.
Definition ags10.h:65
bool set_zero_point_with(uint16_t value)
Sets zero-point with the value.
Definition ags10.cpp:110
bool new_i2c_address(uint8_t newaddress)
Modifies target address of AGS10.
Definition ags10.cpp:89
void dump_config() override
Definition ags10.cpp:58
TEMPLATABLE_VALUE(uint8_t, new_address) void play(Ts... x) override
Definition ags10.h:106
TEMPLATABLE_VALUE(uint16_t, value) TEMPLATABLE_VALUE(AGS10SetZeroPointActionMode
mode void play(Ts... x) override
Definition ags10.h:125
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
Base-class for all sensors.
Definition sensor.h:42
AGS10SetZeroPointActionMode
Definition ags10.h:111
@ FACTORY_DEFAULT
Definition ags10.h:113
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5