mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[modbus_controller] fix incorrect start address for number write (#3073)
This commit is contained in:
		| @@ -57,9 +57,11 @@ void ModbusNumber::control(float value) { | |||||||
|   // Create and send the write command |   // Create and send the write command | ||||||
|   ModbusCommandItem write_cmd; |   ModbusCommandItem write_cmd; | ||||||
|   if (this->register_count == 1 && !this->use_write_multiple_) { |   if (this->register_count == 1 && !this->use_write_multiple_) { | ||||||
|     write_cmd = ModbusCommandItem::create_write_single_command(parent_, this->start_address + this->offset, data[0]); |     // since offset is in bytes and a register is 16 bits we get the start by adding offset/2 | ||||||
|  |     write_cmd = | ||||||
|  |         ModbusCommandItem::create_write_single_command(parent_, this->start_address + this->offset / 2, data[0]); | ||||||
|   } else { |   } else { | ||||||
|     write_cmd = ModbusCommandItem::create_write_multiple_command(parent_, this->start_address + this->offset, |     write_cmd = ModbusCommandItem::create_write_multiple_command(parent_, this->start_address + this->offset / 2, | ||||||
|                                                                  this->register_count, data); |                                                                  this->register_count, data); | ||||||
|   } |   } | ||||||
|   // publish new value |   // publish new value | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user