ESPHome  2024.10.2
growatt_solar.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace growatt_solar {
11 
12 static const float TWO_DEC_UNIT = 0.01;
13 static const float ONE_DEC_UNIT = 0.1;
14 
16  RTU = 0,
18 };
19 
21  public:
22  void loop() override;
23  void update() override;
24  void on_modbus_data(const std::vector<uint8_t> &data) override;
25  void dump_config() override;
26 
27  void set_protocol_version(GrowattProtocolVersion protocol_version) { this->protocol_version_ = protocol_version; }
28 
30 
34 
38 
39  void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor) {
40  this->phases_[phase].voltage_sensor_ = voltage_sensor;
41  }
42  void set_current_sensor(uint8_t phase, sensor::Sensor *current_sensor) {
43  this->phases_[phase].current_sensor_ = current_sensor;
44  }
45  void set_active_power_sensor(uint8_t phase, sensor::Sensor *active_power_sensor) {
46  this->phases_[phase].active_power_sensor_ = active_power_sensor;
47  }
48  void set_voltage_sensor_pv(uint8_t pv, sensor::Sensor *voltage_sensor) {
49  this->pvs_[pv].voltage_sensor_ = voltage_sensor;
50  }
51  void set_current_sensor_pv(uint8_t pv, sensor::Sensor *current_sensor) {
52  this->pvs_[pv].current_sensor_ = current_sensor;
53  }
54  void set_active_power_sensor_pv(uint8_t pv, sensor::Sensor *active_power_sensor) {
55  this->pvs_[pv].active_power_sensor_ = active_power_sensor;
56  }
57 
58  protected:
60  uint32_t last_send_;
61 
62  struct GrowattPhase {
66  } phases_[3];
67  struct GrowattPV {
71  } pvs_[2];
72 
74 
77 
79 
84 };
85 
86 } // namespace growatt_solar
87 } // namespace esphome
struct esphome::growatt_solar::GrowattSolar::GrowattPhase phases_[3]
struct esphome::growatt_solar::GrowattSolar::GrowattPV pvs_[2]
void set_grid_frequency_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:31
void set_protocol_version(GrowattProtocolVersion protocol_version)
Definition: growatt_solar.h:27
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_today_production_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:35
void set_inverter_module_temp_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:37
void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor)
Definition: growatt_solar.h:39
sensor::Sensor * grid_active_power_sensor_
Definition: growatt_solar.h:76
void set_pv_active_power_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:33
void set_current_sensor(uint8_t phase, sensor::Sensor *current_sensor)
Definition: growatt_solar.h:42
void set_grid_active_power_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:32
void set_total_energy_production_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:36
void set_active_power_sensor_pv(uint8_t pv, sensor::Sensor *active_power_sensor)
Definition: growatt_solar.h:54
void set_current_sensor_pv(uint8_t pv, sensor::Sensor *current_sensor)
Definition: growatt_solar.h:51
GrowattProtocolVersion protocol_version_
Definition: growatt_solar.h:83
void on_modbus_data(const std::vector< uint8_t > &data) override
void set_voltage_sensor_pv(uint8_t pv, sensor::Sensor *voltage_sensor)
Definition: growatt_solar.h:48
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57
void set_inverter_status_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:29
void set_active_power_sensor(uint8_t phase, sensor::Sensor *active_power_sensor)
Definition: growatt_solar.h:45
esphome::sensor::Sensor * sensor
Definition: statsd.h:37