Modbus write_registers function support

Hello, I need to write using modbus values ​​to the EV wallbox, but the wallbox cannot write using the function in HA write_register, but only supports writer_registers, which I can do, for example, using an external python script. Is it possible to do this using HA without using an external python script like this one?

from pymodbus.client import ModbusTcpClient
import logging



client = ModbusTcpClient('10.55.253.7', port=8899, timeout=5)


if client.connect():
    print("Connect OK.")
    

    register_address = 1000
    values_to_write = [16] 


    response = client.write_registers(register_address, values_to_write)
    

    if response.isError():
        print("Error write: ", response)
    else:
        print("Value write OK.")


    read_response = client.read_holding_registers(register_address, 1)
    if read_response.isError():
        print("Error read: ", read_response)
    else:
        print("New value: ", read_response.registers[0])
else:
    print("Error connect.")

client.close()

So I have already solved it, if you want to write a value with the write registers function, you need to put the value in square brackets, see:

write_register
value: xxxx

write_registers
value: [xxxx]

or

value:
- xxxx
1 Like