I have made a Modbus MitM module for my Growatt Inverter.
Reading values from the inverter and presenting them to another Modbus Client (Master) works fine.
Also setting values with the MitM module on the Inverter works fine.
However changing settings on the Modbus Client and write them to the MitM module does not work.
Part of the code I use is the following:
preferences:
flash_write_interval: 1h
uart:
- id: mod_bus
tx_pin: 19
rx_pin: 18
baud_rate: 9600
- id: uart_modbus_server
tx_pin: 16
rx_pin: 17
baud_rate: 9600
modbus:
- uart_id: mod_bus
id: modbus1
- uart_id: uart_modbus_server
id: modbus_server
role: server
modbus_controller:
- id: growatt
address: 0x1
update_interval: 10s
modbus_id: modbus1
setup_priority: -10
- id: growatt_server
modbus_id: modbus_server
address: 0x1
server_registers:
- address: 0
value_type: U_WORD
read_lambda: |-
return id(inverter).state;
- address: 122
value_type: U_WORD
read_lambda: |-
return id(antibackflow).state;
- address: 123
value_type: S_WORD
read_lambda: |-
return id(antibackflowrate).state;
number:
- platform: modbus_controller
modbus_controller_id: growatt
id: antibackflowrate
name: "Antibackflow Rate"
address: 123
register_type: holding
value_type: S_WORD
min_value: -1000
max_value: 1000
step: 10
sensor:
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 60s
- platform: modbus_controller
modbus_controller_id: growatt
id: inverter
internal: true
name: "Inverter"
icon: mdi:battery-charging-100
address: 00
register_type: "read"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: growatt
id: runtime
internal: true
name: "Runtime"
address: 57
register_type: "read"
value_type: U_DWORD
on_value:
then:
- sensor.template.publish:
id: runtime2
state: !lambda |-
return x * 0.5;
- platform: modbus_controller
modbus_controller_id: growatt
name: "AntiBackflow"
internal: true
address: 122
register_type: holding
id: antibackflow
Error message on the Modbus client (Master) with MitM module connected and write command issued:
[21:55:56][D][modbus_controller:037]: Modbus command to device=1 register=0x00 countdown=0 no response received - removed from send queue
The MitM module seems to receive the following data at that moment:
[D][uart_debug:114]: <<< 010060000000000000890CA
What am I doing wrong? Is there a way to have a Modbus Client write values to a ESPHome Modbus Server?