esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
294 stars 37 forks source link

[modbus_controller] `max_cmd_retries` works only once when a server becomes offline #6494

Open Sleeper85 opened 4 days ago

Sleeper85 commented 4 days ago

The problem

Hi @martgras @0x3333

I'm testing a client modbus code that queries three different servers. If server 241 becomes offline, after 6 requests, a 1min pause (3s*20) is observed and then the client sends new requests indefinitely without respecting the max_cmd_retries parameters.

Server 1 information continues to be retrieved but server 2 information is lost.

If I reconnect server 241 to the RS485 bus everything works correctly again.

This problem exists with esphome 2024.11.1 but also with 2024.10.3 (before the PR of @0x3333), I have not tested other esphome versions.

The RS485 bus

R120ohm---(server 2)-----(server 1)-----(client)-----(server 241)---R120ohm

Which version of ESPHome has the issue?

2024.11.1

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32-IDF

Board

esp32doit-devkit-v1

Component causing the issue

modbus_controller

Example YAML snippet

modbus_controller:

  - id: modbus1
    modbus_id: modbus_client
    address: 241
    update_interval: 3s
    command_throttle: 5ms
    max_cmd_retries: 3
    offline_skip_updates: 20

  - id: modbus2
    modbus_id: modbus_client
    address: 1
    update_interval: 3s
    command_throttle: 5ms
    max_cmd_retries: 3
    offline_skip_updates: 20

  - id: modbus3
    modbus_id: modbus_client
    address: 2
    update_interval: 3s
    command_throttle: 5ms
    max_cmd_retries: 3
    offline_skip_updates: 20

Anything in the logs that might be useful for us?

[16:20:57][W][modbus_controller:027]: Modbus device=241 set offline
[16:20:57][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:20:58][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:21:00][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:21:01][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:21:02][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:21:03][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue

( 1min pause )

[16:22:00][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:01][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:22:02][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:22:03][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:22:04][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:22:05][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:22:06][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:22:07][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:09][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:22:10][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:22:11][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:22:12][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:22:13][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:14][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:22:15][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:22:16][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:22:18][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:22:19][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:20][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:22:21][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:22:22][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:22:23][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:22:24][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:22:25][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:27][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:22:28][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:22:29][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:22:30][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:22:31][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:32][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:22:33][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:22:34][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:22:36][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:22:37][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:22:38][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
...

[16:23:21][W][modbus_controller:063]: Modbus device=241 back online
[16:23:36][W][modbus_controller:027]: Modbus device=241 set offline
[16:23:36][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:23:37][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:23:38][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:23:39][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:23:40][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:23:42][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:23:43][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue

( 1min pause )

[16:24:39][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:24:40][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:24:41][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:24:42][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:24:43][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:24:44][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:24:46][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:24:47][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:24:48][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:24:49][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:24:50][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:24:51][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:24:52][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:24:54][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:24:55][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:24:56][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:24:57][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:24:58][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:24:59][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
[16:25:00][D][modbus_controller:038]: Modbus command to device=241 register=0x1A no response received - removed from send queue
[16:25:01][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:25:02][D][modbus_controller:038]: Modbus command to device=241 register=0x1B no response received - removed from send queue
[16:25:03][D][modbus_controller:038]: Modbus command to device=241 register=0x05 no response received - removed from send queue
[16:25:04][D][modbus_controller:038]: Modbus command to device=241 register=0x06 no response received - removed from send queue
[16:25:06][D][modbus_controller:038]: Modbus command to device=241 register=0x07 no response received - removed from send queue
[16:25:07][D][modbus_controller:038]: Modbus command to device=241 register=0x01 no response received - removed from send queue
[16:25:08][D][modbus_controller:038]: Modbus command to device=241 register=0x08 no response received - removed from send queue
...

Additional information

No response

0x3333 commented 4 days ago

I need all your yaml file, looks like you have several registers in this server...

Edit 1: If you could post all logs (without redaction), it would help to check the timings. Edit 2: A verbose log would help a lot.

Sleeper85 commented 4 days ago

I could provide you with more logs tomorrow. In the meantime, here are all the YAMLs used.

YamBMS 1.5.2 beta1

YamBMS_multi-node_RS485_modbus

Sleeper85 commented 2 days ago

I need all your yaml file, looks like you have several registers in this server...

Edit 1: If you could post all logs (without redaction), it would help to check the timings. Edit 2: A verbose log would help a lot.

Attached is an export of the full VERBOSE logs without filtering.

logs_device_241_disconnected_from_the_RS485_bus_2024.11.19.zip