ESPHome  2024.11.0
havells_solar.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace havells_solar {
11 
13  public:
14  void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor) {
15  this->phases_[phase].setup = true;
16  this->phases_[phase].voltage_sensor_ = voltage_sensor;
17  }
18  void set_current_sensor(uint8_t phase, sensor::Sensor *current_sensor) {
19  this->phases_[phase].setup = true;
20  this->phases_[phase].current_sensor_ = current_sensor;
21  }
22  void set_voltage_sensor_pv(uint8_t pv, sensor::Sensor *voltage_sensor) {
23  this->pvs_[pv].setup = true;
24  this->pvs_[pv].voltage_sensor_ = voltage_sensor;
25  }
26  void set_current_sensor_pv(uint8_t pv, sensor::Sensor *current_sensor) {
27  this->pvs_[pv].setup = true;
28  this->pvs_[pv].current_sensor_ = current_sensor;
29  }
30  void set_active_power_sensor_pv(uint8_t pv, sensor::Sensor *active_power_sensor) {
31  this->pvs_[pv].setup = true;
32  this->pvs_[pv].active_power_sensor_ = active_power_sensor;
33  }
35  sensor::Sensor *voltage_sampled_by_secondary_cpu_sensor) {
36  this->pvs_[pv].setup = true;
37  this->pvs_[pv].voltage_sampled_by_secondary_cpu_sensor_ = voltage_sampled_by_secondary_cpu_sensor;
38  }
39  void set_insulation_of_p_to_ground_sensor_pv(uint8_t pv, sensor::Sensor *insulation_of_p_to_ground_sensor) {
40  this->pvs_[pv].setup = true;
41  this->pvs_[pv].insulation_of_p_to_ground_sensor_ = insulation_of_p_to_ground_sensor;
42  }
43  void set_frequency_sensor(sensor::Sensor *frequency_sensor) { this->frequency_sensor_ = frequency_sensor; }
44  void set_active_power_sensor(sensor::Sensor *active_power_sensor) {
45  this->active_power_sensor_ = active_power_sensor;
46  }
47  void set_reactive_power_sensor(sensor::Sensor *reactive_power_sensor) {
48  this->reactive_power_sensor_ = reactive_power_sensor;
49  }
50  void set_today_production_sensor(sensor::Sensor *today_production_sensor) {
51  this->today_production_sensor_ = today_production_sensor;
52  }
53  void set_total_energy_production_sensor(sensor::Sensor *total_energy_production_sensor) {
54  this->total_energy_production_sensor_ = total_energy_production_sensor;
55  }
56  void set_total_generation_time_sensor(sensor::Sensor *total_generation_time_sensor) {
57  this->total_generation_time_sensor_ = total_generation_time_sensor;
58  }
59  void set_today_generation_time_sensor(sensor::Sensor *today_generation_time_sensor) {
60  this->today_generation_time_sensor_ = today_generation_time_sensor;
61  }
62  void set_inverter_module_temp_sensor(sensor::Sensor *inverter_module_temp_sensor) {
63  this->inverter_module_temp_sensor_ = inverter_module_temp_sensor;
64  }
65  void set_inverter_inner_temp_sensor(sensor::Sensor *inverter_inner_temp_sensor) {
66  this->inverter_inner_temp_sensor_ = inverter_inner_temp_sensor;
67  }
68  void set_inverter_bus_voltage_sensor(sensor::Sensor *inverter_bus_voltage_sensor) {
69  this->inverter_bus_voltage_sensor_ = inverter_bus_voltage_sensor;
70  }
71  void set_insulation_pv_n_to_ground_sensor(sensor::Sensor *insulation_pv_n_to_ground_sensor) {
72  this->insulation_pv_n_to_ground_sensor_ = insulation_pv_n_to_ground_sensor;
73  }
74  void set_gfci_value_sensor(sensor::Sensor *gfci_value_sensor) { this->gfci_value_sensor_ = gfci_value_sensor; }
75  void set_dci_of_r_sensor(sensor::Sensor *dci_of_r_sensor) { this->dci_of_r_sensor_ = dci_of_r_sensor; }
76  void set_dci_of_s_sensor(sensor::Sensor *dci_of_s_sensor) { this->dci_of_s_sensor_ = dci_of_s_sensor; }
77  void set_dci_of_t_sensor(sensor::Sensor *dci_of_t_sensor) { this->dci_of_t_sensor_ = dci_of_t_sensor; }
78 
79  void update() override;
80 
81  void on_modbus_data(const std::vector<uint8_t> &data) override;
82 
83  void dump_config() override;
84 
85  protected:
86  struct HAVELLSPhase {
87  bool setup{false};
90  } phases_[3];
91  struct HAVELLSPV {
92  bool setup{false};
96  sensor::Sensor *voltage_sampled_by_secondary_cpu_sensor_{nullptr};
97  sensor::Sensor *insulation_of_p_to_ground_sensor_{nullptr};
98  } pvs_[2];
114 };
115 
116 } // namespace havells_solar
117 } // namespace esphome
void set_inverter_module_temp_sensor(sensor::Sensor *inverter_module_temp_sensor)
Definition: havells_solar.h:62
void set_dci_of_t_sensor(sensor::Sensor *dci_of_t_sensor)
Definition: havells_solar.h:77
void set_gfci_value_sensor(sensor::Sensor *gfci_value_sensor)
Definition: havells_solar.h:74
void set_dci_of_r_sensor(sensor::Sensor *dci_of_r_sensor)
Definition: havells_solar.h:75
void set_active_power_sensor(sensor::Sensor *active_power_sensor)
Definition: havells_solar.h:44
sensor::Sensor * today_generation_time_sensor_
sensor::Sensor * total_generation_time_sensor_
void set_reactive_power_sensor(sensor::Sensor *reactive_power_sensor)
Definition: havells_solar.h:47
sensor::Sensor * inverter_module_temp_sensor_
This class simplifies creating components that periodically check a state.
Definition: component.h:283
sensor::Sensor * inverter_bus_voltage_sensor_
struct esphome::havells_solar::HavellsSolar::HAVELLSPhase phases_[3]
void on_modbus_data(const std::vector< uint8_t > &data) override
struct esphome::havells_solar::HavellsSolar::HAVELLSPV pvs_[2]
void set_active_power_sensor_pv(uint8_t pv, sensor::Sensor *active_power_sensor)
Definition: havells_solar.h:30
void set_frequency_sensor(sensor::Sensor *frequency_sensor)
Definition: havells_solar.h:43
void set_dci_of_s_sensor(sensor::Sensor *dci_of_s_sensor)
Definition: havells_solar.h:76
sensor::Sensor * total_energy_production_sensor_
void set_today_generation_time_sensor(sensor::Sensor *today_generation_time_sensor)
Definition: havells_solar.h:59
void set_current_sensor_pv(uint8_t pv, sensor::Sensor *current_sensor)
Definition: havells_solar.h:26
void set_inverter_inner_temp_sensor(sensor::Sensor *inverter_inner_temp_sensor)
Definition: havells_solar.h:65
void set_voltage_sampled_by_secondary_cpu_sensor_pv(uint8_t pv, sensor::Sensor *voltage_sampled_by_secondary_cpu_sensor)
Definition: havells_solar.h:34
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_total_generation_time_sensor(sensor::Sensor *total_generation_time_sensor)
Definition: havells_solar.h:56
void set_current_sensor(uint8_t phase, sensor::Sensor *current_sensor)
Definition: havells_solar.h:18
void set_insulation_pv_n_to_ground_sensor(sensor::Sensor *insulation_pv_n_to_ground_sensor)
Definition: havells_solar.h:71
Base-class for all sensors.
Definition: sensor.h:57
sensor::Sensor * insulation_pv_n_to_ground_sensor_
void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor)
Definition: havells_solar.h:14
void set_inverter_bus_voltage_sensor(sensor::Sensor *inverter_bus_voltage_sensor)
Definition: havells_solar.h:68
void set_total_energy_production_sensor(sensor::Sensor *total_energy_production_sensor)
Definition: havells_solar.h:53
void set_voltage_sensor_pv(uint8_t pv, sensor::Sensor *voltage_sensor)
Definition: havells_solar.h:22
void set_today_production_sensor(sensor::Sensor *today_production_sensor)
Definition: havells_solar.h:50
sensor::Sensor * inverter_inner_temp_sensor_
void set_insulation_of_p_to_ground_sensor_pv(uint8_t pv, sensor::Sensor *insulation_of_p_to_ground_sensor)
Definition: havells_solar.h:39