ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
ags10.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::ags10 {
9
11 public:
15 void set_tvoc(sensor::Sensor *tvoc) { this->tvoc_ = tvoc; }
16
20 void set_version(sensor::Sensor *version) { this->version_ = version; }
21
25 void set_resistance(sensor::Sensor *resistance) { this->resistance_ = resistance; }
26
27 void setup() override;
28
29 void update() override;
30
31 void dump_config() override;
32
38 bool new_i2c_address(uint8_t newaddress);
39
44
49
53 bool set_zero_point_with(uint16_t value);
54
55 protected:
60
65
70
81
85 optional<uint32_t> read_tvoc_();
86
90 optional<uint8_t> read_version_();
91
95 optional<uint32_t> read_resistance_();
96
100 template<size_t N> optional<std::array<uint8_t, N>> read_and_check_(uint8_t a_register);
101};
102
103template<typename... Ts> class AGS10NewI2cAddressAction : public Action<Ts...>, public Parented<AGS10Component> {
104 public:
105 TEMPLATABLE_VALUE(uint8_t, new_address)
106
107 void play(const Ts &...x) override { this->parent_->new_i2c_address(this->new_address_.value(x...)); }
108};
109
111 // Zero-point reset.
113 // Zero-point calibration with current resistance.
115 // Zero-point calibration with custom resistance.
117};
118
119template<typename... Ts> class AGS10SetZeroPointAction : public Action<Ts...>, public Parented<AGS10Component> {
120 public:
121 TEMPLATABLE_VALUE(uint16_t, value)
123
124 void play(const Ts &...x) override {
125 switch (this->mode_.value(x...)) {
126 case FACTORY_DEFAULT:
127 this->parent_->set_zero_point_with_factory_defaults();
128 break;
129 case CURRENT_VALUE:
130 this->parent_->set_zero_point_with_current_resistance();
131 break;
132 case CUSTOM_VALUE:
133 this->parent_->set_zero_point_with(this->value_.value(x...));
134 break;
135 }
136 }
137};
138} // namespace esphome::ags10
BedjetMode mode
BedJet operating mode.
virtual void play(const Ts &...x)=0
Helper class to easily give an object a parent of type T.
Definition helpers.h:1861
This class simplifies creating components that periodically check a state.
Definition component.h:585
optional< std::array< uint8_t, N > > read_and_check_(uint8_t a_register)
Read, checks and returns data from the sensor.
Definition ags10.cpp:175
ErrorCode
Last operation error code.
Definition ags10.h:74
bool set_zero_point_with_factory_defaults()
Sets zero-point with factory defaults.
Definition ags10.cpp:105
optional< uint8_t > read_version_()
Reads and returns a firmware version of AGS10.
Definition ags10.cpp:157
void set_resistance(sensor::Sensor *resistance)
Sets resistance info sensor.
Definition ags10.h:25
enum esphome::ags10::AGS10Component::ErrorCode NONE
sensor::Sensor * tvoc_
TVOC.
Definition ags10.h:59
bool set_zero_point_with_current_resistance()
Sets zero-point with current sensor resistance.
Definition ags10.cpp:107
sensor::Sensor * resistance_
Resistance.
Definition ags10.h:69
void set_tvoc(sensor::Sensor *tvoc)
Sets TVOC sensor.
Definition ags10.h:15
void set_version(sensor::Sensor *version)
Sets version info sensor.
Definition ags10.h:20
optional< uint32_t > read_resistance_()
Reads and returns the resistance of AGS10.
Definition ags10.cpp:166
optional< uint32_t > read_tvoc_()
Reads and returns value of TVOC.
Definition ags10.cpp:130
sensor::Sensor * version_
Firmvare version.
Definition ags10.h:64
bool set_zero_point_with(uint16_t value)
Sets zero-point with the value.
Definition ags10.cpp:109
bool new_i2c_address(uint8_t newaddress)
Modifies target address of AGS10.
Definition ags10.cpp:88
void dump_config() override
Definition ags10.cpp:57
TEMPLATABLE_VALUE(uint8_t, new_address) void play(const Ts &...x) override
Definition ags10.h:105
TEMPLATABLE_VALUE(uint16_t, value) TEMPLATABLE_VALUE(AGS10SetZeroPointActionMode
mode void play(const Ts &...x) override
Definition ags10.h:124
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
Base-class for all sensors.
Definition sensor.h:47
AGS10SetZeroPointActionMode
Definition ags10.h:110
@ FACTORY_DEFAULT
Definition ags10.h:112
uint16_t x
Definition tt21100.cpp:5