5namespace modbus_controller {
 
    7static const char *
const TAG = 
"modbus_controller.select";
 
   14  ESP_LOGD(TAG, 
"New select value %lld from payload", value);
 
   20    if (
val.has_value()) {
 
   22      ESP_LOGV(TAG, 
"lambda returned option %s", new_state->c_str());
 
   27    auto map_it = std::find(this->
mapping_.cbegin(), this->mapping_.cend(), value);
 
   29    if (map_it != this->
mapping_.cend()) {
 
   30      size_t idx = std::distance(this->
mapping_.cbegin(), map_it);
 
   32      ESP_LOGV(TAG, 
"Found option %s for value %lld", new_state->c_str(), value);
 
   34      ESP_LOGE(TAG, 
"No option found for mapping %lld", value);
 
 
   46  size_t idx = std::distance(
options.cbegin(), opt_it);
 
   48  ESP_LOGD(TAG, 
"Found value %lld for option '%s'", *mapval, value.c_str());
 
   50  std::vector<uint16_t> data;
 
   54    if (
val.has_value()) {
 
   56      ESP_LOGV(TAG, 
"write_lambda returned mapping value %lld", *mapval);
 
   58      ESP_LOGD(TAG, 
"Communication handled by write_lambda - exiting control");
 
   66    ESP_LOGV(TAG, 
"Using payload from write lambda");
 
   70    ESP_LOGW(TAG, 
"No payload was created for updating select");
 
 
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.
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.
void queue_command(const ModbusCommandItem &command)
queues a modbus command in the send queue
optional< write_transform_func_t > write_transform_func_
void parse_and_publish(const std::vector< uint8_t > &data) override
std::vector< int64_t > mapping_
void dump_config() override
optional< transform_func_t > transform_func_
ModbusController * parent_
void control(const std::string &value) override
SensorValueType sensor_value_type
value_type const & value() const
void publish_state(const std::string &state)
const std::vector< std::string > & get_options() const
void number_to_payload(std::vector< uint16_t > &data, int64_t value, SensorValueType value_type)
Convert float value to vector<uint16_t> suitable for sending.
int64_t payload_to_number(const std::vector< uint8_t > &data, SensorValueType sensor_value_type, uint8_t offset, uint32_t bitmask)
Convert vector<uint8_t> response payload to number.
Providing packet encoding functions for exchanging data with a remote host.