ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
pylontech_sensor.h
Go to the documentation of this file.
1#pragma once
2
3#include "../pylontech.h"
5
6namespace esphome::pylontech {
7
8class PylontechSensor final : public PylontechListener {
9 public:
10 explicit PylontechSensor(uint8_t bat_num) : PylontechListener(bat_num) {}
11 void dump_config() override;
12
13 SUB_SENSOR(voltage)
14 SUB_SENSOR(current)
16 SUB_SENSOR(temperature_low)
17 SUB_SENSOR(temperature_high)
18 SUB_SENSOR(voltage_low)
19 SUB_SENSOR(voltage_high)
20 SUB_SENSOR(coulomb)
21 SUB_SENSOR(mos_temperature)
22
23 void on_line_read(LineContents *line) override;
24
25#ifdef PYLONTECH_SENSOR_CELL_COUNT
26 void add_cell(uint8_t cell, sensor::Sensor *voltage, sensor::Sensor *temperature) {
27 this->cells_.push_back({voltage, temperature, cell});
28 }
29 void on_cells_read(const CellArray &cells, cell_mask_t read) override;
30
31 protected:
38#endif
39};
40
41} // namespace esphome::pylontech
Minimal static vector - saves memory by avoiding std::vector overhead.
Definition helpers.h:286
virtual void on_line_read(LineContents *line)=0
Called only with records for this listener's battery.
std::array< CellContents, MAX_CELLS > CellArray
Definition pylontech.h:38
void on_cells_read(const CellArray &cells, cell_mask_t read) override
SUB_SENSOR(voltage) SUB_SENSOR(current) SUB_SENSOR(temperature) SUB_SENSOR(temperature_low) SUB_SENSOR(temperature_high) SUB_SENSOR(voltage_low) SUB_SENSOR(voltage_high) SUB_SENSOR(coulomb) SUB_SENSOR(mos_temperature) void on_line_read(LineContents *line) override
StaticVector< CellSensors, PYLONTECH_SENSOR_CELL_COUNT > cells_
void add_cell(uint8_t cell, sensor::Sensor *voltage, sensor::Sensor *temperature)
Base-class for all sensors.
Definition sensor.h:47
uint16_t cell_mask_t
Definition pylontech.h:21
uint16_t temperature
Definition sun_gtil2.cpp:12