mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-26 07:38:30 +02:00
Modbus number/output use write single (#2896)
Co-authored-by: Martin <25747549+martgras@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
24ec5a6e9d
commit
c490388e80
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user