ESPHome  2024.11.2
cse7766.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace cse7766 {
9 
11  public:
12  void set_voltage_sensor(sensor::Sensor *voltage_sensor) { voltage_sensor_ = voltage_sensor; }
13  void set_current_sensor(sensor::Sensor *current_sensor) { current_sensor_ = current_sensor; }
14  void set_power_sensor(sensor::Sensor *power_sensor) { power_sensor_ = power_sensor; }
15  void set_energy_sensor(sensor::Sensor *energy_sensor) { energy_sensor_ = energy_sensor; }
16  void set_apparent_power_sensor(sensor::Sensor *apparent_power_sensor) {
17  apparent_power_sensor_ = apparent_power_sensor;
18  }
19  void set_reactive_power_sensor(sensor::Sensor *reactive_power_sensor) {
20  reactive_power_sensor_ = reactive_power_sensor;
21  }
22  void set_power_factor_sensor(sensor::Sensor *power_factor_sensor) { power_factor_sensor_ = power_factor_sensor; }
23 
24  void loop() override;
25  float get_setup_priority() const override;
26  void dump_config() override;
27 
28  protected:
29  bool check_byte_();
30  void parse_data_();
31  uint32_t get_24_bit_uint_(uint8_t start_index);
32 
33  uint8_t raw_data_[24];
34  uint8_t raw_data_index_{0};
35  uint32_t last_transmission_{0};
43  uint32_t cf_pulses_total_{0};
44  uint16_t cf_pulses_last_{0};
45 };
46 
47 } // namespace cse7766
48 } // namespace esphome
sensor::Sensor * power_sensor_
Definition: cse7766.h:38
void set_current_sensor(sensor::Sensor *current_sensor)
Definition: cse7766.h:13
sensor::Sensor * power_factor_sensor_
Definition: cse7766.h:42
uint32_t get_24_bit_uint_(uint8_t start_index)
Definition: cse7766.cpp:233
void set_voltage_sensor(sensor::Sensor *voltage_sensor)
Definition: cse7766.h:12
sensor::Sensor * energy_sensor_
Definition: cse7766.h:39
void set_power_factor_sensor(sensor::Sensor *power_factor_sensor)
Definition: cse7766.h:22
void set_apparent_power_sensor(sensor::Sensor *apparent_power_sensor)
Definition: cse7766.h:16
void set_reactive_power_sensor(sensor::Sensor *reactive_power_sensor)
Definition: cse7766.h:19
void set_energy_sensor(sensor::Sensor *energy_sensor)
Definition: cse7766.h:15
void set_power_sensor(sensor::Sensor *power_sensor)
Definition: cse7766.h:14
float get_setup_priority() const override
Definition: cse7766.cpp:40
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
sensor::Sensor * current_sensor_
Definition: cse7766.h:37
Base-class for all sensors.
Definition: sensor.h:57
sensor::Sensor * apparent_power_sensor_
Definition: cse7766.h:40
sensor::Sensor * voltage_sensor_
Definition: cse7766.h:36
sensor::Sensor * reactive_power_sensor_
Definition: cse7766.h:41