ESPHome
2025.5.0
Loading...
Searching...
No Matches
esphome
components
pylontech
pylontech.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/core/defines.h
"
5
#include "
esphome/components/uart/uart.h
"
6
7
namespace
esphome
{
8
namespace
pylontech {
9
10
static
const
uint8_t NUM_BUFFERS = 20;
11
static
const
uint8_t TEXT_SENSOR_MAX_LEN = 8;
12
13
class
PylontechListener
{
14
public
:
15
struct
LineContents
{
16
int
bat_num
= 0,
volt
,
curr
,
tempr
,
tlow
,
thigh
,
vlow
,
vhigh
,
coulomb
,
mostempr
;
17
char
base_st
[TEXT_SENSOR_MAX_LEN],
volt_st
[TEXT_SENSOR_MAX_LEN],
curr_st
[TEXT_SENSOR_MAX_LEN],
18
temp_st
[TEXT_SENSOR_MAX_LEN];
19
};
20
21
virtual
void
on_line_read
(
LineContents
*line);
22
virtual
void
dump_config
();
23
};
24
25
class
PylontechComponent
:
public
PollingComponent
,
public
uart::UARTDevice
{
26
public
:
27
PylontechComponent
();
28
30
void
update
()
override
;
32
void
loop
()
override
;
34
void
setup
()
override
;
35
void
dump_config
()
override
;
36
37
float
get_setup_priority
()
const override
;
38
39
void
register_listener
(
PylontechListener
*listener) { this->
listeners_
.push_back(listener); }
40
41
protected
:
42
void
process_line_
(std::string &buffer);
43
44
// ring buffer
45
std::string
buffer_
[NUM_BUFFERS];
46
int
buffer_index_write_
= 0;
47
int
buffer_index_read_
= 0;
48
49
std::vector<PylontechListener *>
listeners_
{};
50
};
51
52
}
// namespace pylontech
53
}
// namespace esphome
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:301
esphome::pylontech::PylontechComponent
Definition
pylontech.h:25
esphome::pylontech::PylontechComponent::loop
void loop() override
Read data once available.
Definition
pylontech.cpp:37
esphome::pylontech::PylontechComponent::buffer_index_write_
int buffer_index_write_
Definition
pylontech.h:46
esphome::pylontech::PylontechComponent::listeners_
std::vector< PylontechListener * > listeners_
Definition
pylontech.h:49
esphome::pylontech::PylontechComponent::process_line_
void process_line_(std::string &buffer)
Definition
pylontech.cpp:65
esphome::pylontech::PylontechComponent::PylontechComponent
PylontechComponent()
Definition
pylontech.cpp:12
esphome::pylontech::PylontechComponent::buffer_index_read_
int buffer_index_read_
Definition
pylontech.h:47
esphome::pylontech::PylontechComponent::update
void update() override
Schedule data readings.
Definition
pylontech.cpp:35
esphome::pylontech::PylontechComponent::setup
void setup() override
Setup the sensor and test for a connection.
Definition
pylontech.cpp:28
esphome::pylontech::PylontechComponent::register_listener
void register_listener(PylontechListener *listener)
Definition
pylontech.h:39
esphome::pylontech::PylontechComponent::buffer_
std::string buffer_[NUM_BUFFERS]
Definition
pylontech.h:45
esphome::pylontech::PylontechComponent::dump_config
void dump_config() override
Definition
pylontech.cpp:14
esphome::pylontech::PylontechComponent::get_setup_priority
float get_setup_priority() const override
Definition
pylontech.cpp:101
esphome::pylontech::PylontechListener
Definition
pylontech.h:13
esphome::pylontech::PylontechListener::dump_config
virtual void dump_config()
esphome::pylontech::PylontechListener::on_line_read
virtual void on_line_read(LineContents *line)
esphome::uart::UARTDevice
Definition
uart.h:12
component.h
defines.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
esphome::pylontech::PylontechListener::LineContents
Definition
pylontech.h:15
esphome::pylontech::PylontechListener::LineContents::tlow
int tlow
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::coulomb
int coulomb
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::volt
int volt
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::base_st
char base_st[TEXT_SENSOR_MAX_LEN]
Definition
pylontech.h:17
esphome::pylontech::PylontechListener::LineContents::temp_st
char temp_st[TEXT_SENSOR_MAX_LEN]
Definition
pylontech.h:18
esphome::pylontech::PylontechListener::LineContents::vlow
int vlow
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::bat_num
int bat_num
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::curr_st
char curr_st[TEXT_SENSOR_MAX_LEN]
Definition
pylontech.h:17
esphome::pylontech::PylontechListener::LineContents::thigh
int thigh
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::mostempr
int mostempr
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::vhigh
int vhigh
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::volt_st
char volt_st[TEXT_SENSOR_MAX_LEN]
Definition
pylontech.h:17
esphome::pylontech::PylontechListener::LineContents::tempr
int tempr
Definition
pylontech.h:16
esphome::pylontech::PylontechListener::LineContents::curr
int curr
Definition
pylontech.h:16
uart.h
Generated by
1.12.0