ESPHome 2025.5.0
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, "Pylontech Text Sensor:");
14 ESP_LOGCONFIG(TAG, " Battery %d", this->bat_num_);
15 LOG_TEXT_SENSOR(" ", "Base state", this->base_state_text_sensor_);
16 LOG_TEXT_SENSOR(" ", "Voltage state", this->voltage_state_text_sensor_);
17 LOG_TEXT_SENSOR(" ", "Current state", this->current_state_text_sensor_);
18 LOG_TEXT_SENSOR(" ", "Temperature state", this->temperature_state_text_sensor_);
19}
20
22 if (this->bat_num_ != line->bat_num) {
23 return;
24 }
25 if (this->base_state_text_sensor_ != nullptr) {
26 this->base_state_text_sensor_->publish_state(std::string(line->base_st));
27 }
28 if (this->voltage_state_text_sensor_ != nullptr) {
29 this->voltage_state_text_sensor_->publish_state(std::string(line->volt_st));
30 }
31 if (this->current_state_text_sensor_ != nullptr) {
32 this->current_state_text_sensor_->publish_state(std::string(line->curr_st));
33 }
34 if (this->temperature_state_text_sensor_ != nullptr) {
35 this->temperature_state_text_sensor_->publish_state(std::string(line->temp_st));
36 }
37}
38
39} // namespace pylontech
40} // namespace esphome
virtual void on_line_read(LineContents *line)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7