ESPHome 2025.6.3
Loading...
Searching...
No Matches
pylontech_text_sensor.cpp
Go to the documentation of this file.
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace pylontech {
7
8static const char *const TAG = "pylontech.textsensor";
9
10PylontechTextSensor::PylontechTextSensor(int8_t bat_num) { this->bat_num_ = bat_num; }
11
13 ESP_LOGCONFIG(TAG,
14 "Pylontech Text Sensor:\n"
15 " Battery %d",
16 this->bat_num_);
17 LOG_TEXT_SENSOR(" ", "Base state", this->base_state_text_sensor_);
18 LOG_TEXT_SENSOR(" ", "Voltage state", this->voltage_state_text_sensor_);
19 LOG_TEXT_SENSOR(" ", "Current state", this->current_state_text_sensor_);
20 LOG_TEXT_SENSOR(" ", "Temperature state", this->temperature_state_text_sensor_);
21}
22
24 if (this->bat_num_ != line->bat_num) {
25 return;
26 }
27 if (this->base_state_text_sensor_ != nullptr) {
28 this->base_state_text_sensor_->publish_state(std::string(line->base_st));
29 }
30 if (this->voltage_state_text_sensor_ != nullptr) {
31 this->voltage_state_text_sensor_->publish_state(std::string(line->volt_st));
32 }
33 if (this->current_state_text_sensor_ != nullptr) {
34 this->current_state_text_sensor_->publish_state(std::string(line->curr_st));
35 }
36 if (this->temperature_state_text_sensor_ != nullptr) {
37 this->temperature_state_text_sensor_->publish_state(std::string(line->temp_st));
38 }
39}
40
41} // namespace pylontech
42} // namespace esphome
virtual void on_line_read(LineContents *line)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7