ESPHome  2022.12.8
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 update() override;
23  void on_modbus_data(const std::vector<uint8_t> &data) override;
24  void dump_config() override;
25 
26  void set_protocol_version(GrowattProtocolVersion protocol_version) { this->protocol_version_ = protocol_version; }
27 
29 
33 
37 
38  void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor) {
39  this->phases_[phase].voltage_sensor_ = voltage_sensor;
40  }
41  void set_current_sensor(uint8_t phase, sensor::Sensor *current_sensor) {
42  this->phases_[phase].current_sensor_ = current_sensor;
43  }
44  void set_active_power_sensor(uint8_t phase, sensor::Sensor *active_power_sensor) {
45  this->phases_[phase].active_power_sensor_ = active_power_sensor;
46  }
47  void set_voltage_sensor_pv(uint8_t pv, sensor::Sensor *voltage_sensor) {
48  this->pvs_[pv].voltage_sensor_ = voltage_sensor;
49  }
50  void set_current_sensor_pv(uint8_t pv, sensor::Sensor *current_sensor) {
51  this->pvs_[pv].current_sensor_ = current_sensor;
52  }
53  void set_active_power_sensor_pv(uint8_t pv, sensor::Sensor *active_power_sensor) {
54  this->pvs_[pv].active_power_sensor_ = active_power_sensor;
55  }
56 
57  protected:
58  struct GrowattPhase {
62  } phases_[3];
63  struct GrowattPV {
67  } pvs_[2];
68 
70 
73 
75 
80 };
81 
82 } // namespace growatt_solar
83 } // 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:30
void set_protocol_version(GrowattProtocolVersion protocol_version)
Definition: growatt_solar.h:26
This class simplifies creating components that periodically check a state.
Definition: component.h:267
void set_today_production_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:34
void set_inverter_module_temp_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:36
void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor)
Definition: growatt_solar.h:38
sensor::Sensor * grid_active_power_sensor_
Definition: growatt_solar.h:72
void set_pv_active_power_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:32
void set_current_sensor(uint8_t phase, sensor::Sensor *current_sensor)
Definition: growatt_solar.h:41
void set_grid_active_power_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:31
void set_total_energy_production_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:35
void set_active_power_sensor_pv(uint8_t pv, sensor::Sensor *active_power_sensor)
Definition: growatt_solar.h:53
void set_current_sensor_pv(uint8_t pv, sensor::Sensor *current_sensor)
Definition: growatt_solar.h:50
GrowattProtocolVersion protocol_version_
Definition: growatt_solar.h:79
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:47
Definition: a4988.cpp:4
Base-class for all sensors.
Definition: sensor.h:50
void set_inverter_status_sensor(sensor::Sensor *sensor)
Definition: growatt_solar.h:28
void set_active_power_sensor(uint8_t phase, sensor::Sensor *active_power_sensor)
Definition: growatt_solar.h:44