6 namespace modbus_controller {
8 static const char *
const TAG =
"modbus.number";
18 if (
val.has_value()) {
19 ESP_LOGV(TAG,
"Value overwritten by lambda");
23 ESP_LOGD(TAG,
"Number new state : %.02f", result);
30 std::vector<uint16_t> data;
31 float write_value = value;
38 if (
val.has_value()) {
39 ESP_LOGV(TAG,
"Value overwritten by lambda");
40 write_value =
val.value();
42 ESP_LOGV(TAG,
"Communication handled by lambda - exiting control");
60 "Updating register: connected Sensor=%s start address=0x%X register count=%d new value=%.02f (val=%.02f)",
74 const std::vector<uint8_t> &data) {
SensorValueType sensor_value_type
void queue_command(const ModbusCommandItem &command)
queues a modbus command in the send queue
std::string format_hex_pretty(const uint8_t *data, size_t length)
Format the byte array data of length len in pretty-printed, human-readable hex.
optional< write_transform_func_t > write_transform_func_
ModbusRegisterType register_type
std::vector< uint16_t > float_to_payload(float value, SensorValueType value_type)
void on_write_register_response(ModbusRegisterType register_type, uint16_t start_address, const std::vector< uint8_t > &data)
default delegate called by process_modbus_data when a response for a write response has retrieved fro...
void publish_state(float state)
static ModbusCommandItem create_write_single_command(ModbusController *modbusdevice, uint16_t start_address, uint16_t value)
Create modbus write multiple registers command Function 16 (10hex) Write Multiple Registers...
ModbusController * parent_
ModbusRegisterType register_type
float payload_to_float(const std::vector< uint8_t > &data, const SensorItem &item)
Convert vector<uint8_t> response payload to float.
void parse_and_publish(const std::vector< uint8_t > &data) override
std::function< void(ModbusRegisterType register_type, uint16_t start_address, const std::vector< uint8_t > &data)> on_data_func
void dump_config() override
static ModbusCommandItem create_write_multiple_command(ModbusController *modbusdevice, uint16_t start_address, uint16_t register_count, const std::vector< uint16_t > &values)
Create modbus read command Function code 02-04.
optional< transform_func_t > transform_func_
Implementation of SPI Controller mode.
void control(float value) override
static ModbusCommandItem create_custom_command(ModbusController *modbusdevice, const std::vector< uint8_t > &values, std::function< void(ModbusRegisterType register_type, uint16_t start_address, const std::vector< uint8_t > &data)> &&handler=nullptr)
Create custom modbus command.
const StringRef & get_name() const