[modbus] Only apply turnaround delay after broadcasts (#17209)

This commit is contained in:
Jonathan Swoboda
2026-06-25 11:38:34 -04:00
committed by GitHub
parent 18c7f60410
commit 1d5490fd91
4 changed files with 93 additions and 5 deletions
@@ -0,0 +1,56 @@
esphome:
name: uart-mock-modbus-bcast
host:
api:
logger:
level: VERBOSE
external_components:
- source:
type: local
path: EXTERNAL_COMPONENT_PATH
# Dummy uart entry to satisfy modbus's DEPENDENCIES = ["uart"]
# The actual UART bus used is the uart_mock component below
uart:
baud_rate: 115200
port: /dev/null
# No on_tx injection: a broadcast (address 0) gets no reply on a real bus.
uart_mock:
- id: virtual_uart
baud_rate: 9600
auto_start: true
debug:
modbus:
- uart_id: virtual_uart
id: virtual_modbus
role: client
send_wait_time: 200ms
turnaround_time: 10ms
modbus_controller:
- address: 0
modbus_id: virtual_modbus
update_interval: 60s
id: modbus_controller_bcast
number:
- platform: modbus_controller
modbus_controller_id: modbus_controller_bcast
id: bcast_write
name: "bcast_write"
address: 0x01
register_type: holding
value_type: U_WORD
min_value: 0
max_value: 65535
interval:
- interval: 400ms
then:
- number.set:
id: bcast_write
value: 42