ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
modbus_textsensor.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <vector>
8
10
11enum class RawEncoding { NONE = 0, HEXBYTES = 1, COMMA = 2, ANSI = 3 };
12
14 public:
16 uint16_t response_bytes, RawEncoding encode, uint16_t skip_updates, bool force_new_range) {
17 this->register_type = register_type;
18 this->start_address = start_address;
19 this->offset = offset;
20 this->response_bytes = response_bytes;
21 this->register_count = register_count;
22 this->encode_ = encode;
23 this->skip_updates = skip_updates;
24 this->bitmask = 0xFFFFFFFF;
26 this->force_new_range = force_new_range;
27 }
28
29 void dump_config() override;
30
31 void parse_and_publish(const std::vector<uint8_t> &data) override;
32 using transform_func_t = optional<std::string> (*)(ModbusTextSensor *, std::string, const std::vector<uint8_t> &);
34
35 protected:
36 optional<transform_func_t> transform_func_{nullopt};
37
39};
40
41} // namespace esphome::modbus_controller
ESPDEPRECATED("set_retry is deprecated and will be removed in 2026.8.0. Use set_timeout or set_interval instead.", "2026.2.0") void set_retry(const std uint32_t uint8_t std::function< RetryResult(uint8_t)> && f
Definition component.h:454
void parse_and_publish(const std::vector< uint8_t > &data) override
ModbusTextSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint8_t register_count, uint16_t response_bytes, RawEncoding encode, uint16_t skip_updates, bool force_new_range)
optional< std::string >(*)(ModbusTextSensor *, std::string, const std::vector< uint8_t > &) transform_func_t
const std::vector< uint8_t > & data