write()#

ModbusDevice.write(
alias: str,
value: float | int | bool | str,
**kwargs,
) → Command[source]#

Write value to the register named alias.

value is in physical units when a scale is configured. For coils, pass True/False. For registers with a write_value_map, pass the string key to look up the mapped value.

Raises:
  • TypeError – Value type does not match the register’s data type.

  • KeyError – String value not found in write_value_map.

  • ValueError – Read-only register, value violates write_min/write_max, or scaled raw is out of range for the data type.