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