ESPHome  2024.4.0
pmwcs3.h
Go to the documentation of this file.
1 #pragma once
6 
7 // ref:
8 // https://github.com/tinovi/i2cArduino/blob/master/i2cArduino.h
9 
10 namespace esphome {
11 namespace pmwcs3 {
12 
14  public:
15  void setup() override;
16  void update() override;
17  void dump_config() override;
18  float get_setup_priority() const override;
19 
20  void set_e25_sensor(sensor::Sensor *e25_sensor) { e25_sensor_ = e25_sensor; }
21  void set_ec_sensor(sensor::Sensor *ec_sensor) { ec_sensor_ = ec_sensor; }
22  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
23  void set_vwc_sensor(sensor::Sensor *vwc_sensor) { vwc_sensor_ = vwc_sensor; }
24 
25  void new_i2c_address(uint8_t newaddress);
26  void air_calibration();
27  void water_calibration();
28 
29  protected:
30  void read_data_();
31 
36 };
37 
38 template<typename... Ts> class PMWCS3AirCalibrationAction : public Action<Ts...> {
39  public:
40  PMWCS3AirCalibrationAction(PMWCS3Component *parent) : parent_(parent) {}
41 
42  void play(Ts... x) override { this->parent_->air_calibration(); }
43 
44  protected:
46 };
47 
48 template<typename... Ts> class PMWCS3WaterCalibrationAction : public Action<Ts...> {
49  public:
50  PMWCS3WaterCalibrationAction(PMWCS3Component *parent) : parent_(parent) {}
51 
52  void play(Ts... x) override { this->parent_->water_calibration(); }
53 
54  protected:
56 };
57 
58 template<typename... Ts> class PMWCS3NewI2cAddressAction : public Action<Ts...> {
59  public:
60  PMWCS3NewI2cAddressAction(PMWCS3Component *parent) : parent_(parent) {}
61  TEMPLATABLE_VALUE(int, new_address)
62 
63  void play(Ts... x) override { this->parent_->new_i2c_address(this->new_address_.value(x...)); }
64 
65  protected:
67 };
68 
69 } // namespace pmwcs3
70 } // namespace esphome
sensor::Sensor * temperature_sensor_
Definition: pmwcs3.h:34
float get_setup_priority() const override
Definition: pmwcs3.cpp:58
uint16_t x
Definition: tt21100.cpp:17
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_vwc_sensor(sensor::Sensor *vwc_sensor)
Definition: pmwcs3.h:23
void dump_config() override
Definition: pmwcs3.cpp:60
void new_i2c_address(uint8_t newaddress)
Definition: pmwcs3.cpp:26
sensor::Sensor * vwc_sensor_
Definition: pmwcs3.h:35
PMWCS3AirCalibrationAction(PMWCS3Component *parent)
Definition: pmwcs3.h:40
sensor::Sensor * e25_sensor_
Definition: pmwcs3.h:32
PMWCS3WaterCalibrationAction(PMWCS3Component *parent)
Definition: pmwcs3.h:50
TEMPLATABLE_VALUE(int, new_address) void play(Ts... x) override
Definition: pmwcs3.h:61
sensor::Sensor * ec_sensor_
Definition: pmwcs3.h:33
void set_e25_sensor(sensor::Sensor *e25_sensor)
Definition: pmwcs3.h:20
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition: pmwcs3.h:22
PMWCS3NewI2cAddressAction(PMWCS3Component *parent)
Definition: pmwcs3.h:60
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57
void set_ec_sensor(sensor::Sensor *ec_sensor)
Definition: pmwcs3.h:21
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133