ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
cse7766
cse7766.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/core/helpers.h
"
5
#include "
esphome/components/sensor/sensor.h
"
6
#include "
esphome/components/uart/uart.h
"
7
8
namespace
esphome::cse7766
{
9
10
static
constexpr
size_t
CSE7766_RAW_DATA_SIZE = 24;
11
12
class
CSE7766Component
final :
public
Component
,
public
uart::UARTDevice
{
13
SUB_SENSOR(voltage)
14
SUB_SENSOR(current)
15
SUB_SENSOR(power)
16
SUB_SENSOR(energy)
17
SUB_SENSOR(apparent_power)
18
SUB_SENSOR(reactive_power)
19
SUB_SENSOR(power_factor)
20
21
public
:
22
void
loop
()
override
;
23
void
dump_config()
override
;
24
25
protected
:
26
bool
check_byte_
();
27
void
parse_data_
();
28
uint32_t
get_24_bit_uint_
(uint8_t start_index)
const
{
29
return
encode_uint24
(this->
raw_data_
[start_index], this->
raw_data_
[start_index + 1],
30
this->
raw_data_
[start_index + 2]);
31
}
32
33
uint8_t
raw_data_
[CSE7766_RAW_DATA_SIZE];
34
uint8_t
raw_data_index_
{0};
35
uint16_t
cf_pulses_last_
{0};
36
uint32_t
last_transmission_
{0};
37
uint32_t
cf_pulses_total_
{0};
38
// Power cycle of the last frame that carried a new power measurement, 0 if none
39
uint32_t
last_power_cycle_
{0};
40
};
41
42
}
// namespace esphome::cse7766
esphome::Component
Definition
component.h:147
esphome::Component::loop
virtual void loop()
This method will be called repeatedly.
Definition
component.cpp:86
esphome::cse7766::CSE7766Component
Definition
cse7766.h:12
esphome::cse7766::CSE7766Component::check_byte_
bool check_byte_()
Definition
cse7766.cpp:50
esphome::cse7766::CSE7766Component::get_24_bit_uint_
uint32_t get_24_bit_uint_(uint8_t start_index) const
Definition
cse7766.h:28
esphome::cse7766::CSE7766Component::last_power_cycle_
uint32_t last_power_cycle_
Definition
cse7766.h:39
esphome::cse7766::CSE7766Component::cf_pulses_total_
uint32_t cf_pulses_total_
Definition
cse7766.h:37
esphome::cse7766::CSE7766Component::parse_data_
void parse_data_()
Definition
cse7766.cpp:78
esphome::cse7766::CSE7766Component::raw_data_index_
uint8_t raw_data_index_
Definition
cse7766.h:34
esphome::cse7766::CSE7766Component::last_transmission_
uint32_t last_transmission_
Definition
cse7766.h:36
esphome::cse7766::CSE7766Component::raw_data_
uint8_t raw_data_[CSE7766_RAW_DATA_SIZE]
Definition
cse7766.h:33
esphome::cse7766::CSE7766Component::cf_pulses_last_
uint16_t cf_pulses_last_
Definition
cse7766.h:35
esphome::uart::UARTDevice
Definition
uart.h:15
component.h
helpers.h
esphome::cse7766
Definition
cse7766.cpp:7
esphome::encode_uint24
constexpr uint32_t encode_uint24(uint8_t byte1, uint8_t byte2, uint8_t byte3)
Encode a 24-bit value given three bytes in most to least significant byte order.
Definition
helpers.h:1047
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
sensor.h
uart.h
Generated by
1.12.0