ESPHome 2025.8.0b2
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
111 template<size_t N> uint8_t calc_crc8_(std::array<uint8_t, N> dat, uint8_t num);
112};
113
114template<typename... Ts> class AGS10NewI2cAddressAction : public Action<Ts...>, public Parented<AGS10Component> {
115 public:
116 TEMPLATABLE_VALUE(uint8_t, new_address)
117
118 void play(Ts... x) override { this->parent_->new_i2c_address(this->new_address_.value(x...)); }
119};
120
122 // Zero-point reset.
124 // Zero-point calibration with current resistance.
126 // Zero-point calibration with custom resistance.
128};
129
130template<typename... Ts> class AGS10SetZeroPointAction : public Action<Ts...>, public Parented<AGS10Component> {
131 public:
132 TEMPLATABLE_VALUE(uint16_t, value)
134
135 void play(Ts... x) override {
136 switch (this->mode_.value(x...)) {
137 case FACTORY_DEFAULT:
138 this->parent_->set_zero_point_with_factory_defaults();
139 break;
140 case CURRENT_VALUE:
141 this->parent_->set_zero_point_with_current_resistance();
142 break;
143 case CUSTOM_VALUE:
144 this->parent_->set_zero_point_with(this->value_.value(x...));
145 break;
146 }
147 }
148};
149} // namespace ags10
150} // 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:656
This class simplifies creating components that periodically check a state.
Definition component.h:425
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
uint8_t calc_crc8_(std::array< uint8_t, N > dat, uint8_t num)
Calculates CRC8 value.
Definition ags10.cpp:196
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:116
TEMPLATABLE_VALUE(uint16_t, value) TEMPLATABLE_VALUE(AGS10SetZeroPointActionMode
mode void play(Ts... x) override
Definition ags10.h:135
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:59
AGS10SetZeroPointActionMode
Definition ags10.h:121
@ FACTORY_DEFAULT
Definition ags10.h:123
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5