Modbus number/output use write single (#2896)

Co-authored-by: Martin <25747549+martgras@users.noreply.github.com>
This commit is contained in:
Guillermo Ruffino
2021-12-09 17:44:43 -03:00
committed by GitHub
parent 24ec5a6e9d
commit c490388e80
8 changed files with 27 additions and 6 deletions
@@ -40,8 +40,14 @@ void ModbusOutput::write_state(float value) {
this->start_address, this->register_count, value, original_value);
// Create and send the write command
auto write_cmd =
ModbusCommandItem::create_write_multiple_command(parent_, this->start_address, this->register_count, data);
// Create and send the write command
ModbusCommandItem write_cmd;
if (this->register_count == 1 && !this->use_write_multiple_) {
write_cmd = ModbusCommandItem::create_write_single_command(parent_, this->start_address + this->offset, data[0]);
} else {
write_cmd = ModbusCommandItem::create_write_multiple_command(parent_, this->start_address + this->offset,
this->register_count, data);
}
parent_->queue_command(write_cmd);
}