ESPHome  2022.12.8
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 
17  void loop() override;
18  float get_setup_priority() const override;
19  void update() override;
20  void dump_config() override;
21 
22  protected:
23  bool check_byte_();
24  void parse_data_();
25  uint32_t get_24_bit_uint_(uint8_t start_index);
26 
27  uint8_t raw_data_[24];
28  uint8_t raw_data_index_{0};
29  uint32_t last_transmission_{0};
34  float voltage_acc_{0.0f};
35  float current_acc_{0.0f};
36  float power_acc_{0.0f};
37  float energy_total_{0.0f};
38  uint32_t cf_pulses_last_{0};
39  uint32_t voltage_counts_{0};
40  uint32_t current_counts_{0};
41  uint32_t power_counts_{0};
42  // Setting this to 1 means it will always publish 0 once at startup
43  uint32_t energy_total_counts_{1};
44 };
45 
46 } // namespace cse7766
47 } // namespace esphome
sensor::Sensor * power_sensor_
Definition: cse7766.h:32
void set_current_sensor(sensor::Sensor *current_sensor)
Definition: cse7766.h:13
uint32_t get_24_bit_uint_(uint8_t start_index)
Definition: cse7766.cpp:190
void set_voltage_sensor(sensor::Sensor *voltage_sensor)
Definition: cse7766.h:12
This class simplifies creating components that periodically check a state.
Definition: component.h:267
sensor::Sensor * energy_sensor_
Definition: cse7766.h:33
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:37
Definition: a4988.cpp:4
sensor::Sensor * current_sensor_
Definition: cse7766.h:31
Base-class for all sensors.
Definition: sensor.h:50
sensor::Sensor * voltage_sensor_
Definition: cse7766.h:30