core: Modbus Integration Error for Slave ID 0 After Upgrade to Home Assistant 2025.1

The problem

After upgrading to Home Assistant version 2025.1, the Modbus integration started failing for a specific device with slave ID 0. Other Modbus devices configured in Home Assistant continue to work without issues. The following error is logged:

2025-01-04 13:43:35.328 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40560 -> Exception Response(131, 3, IllegalValue)

The error appears to be related to the Modbus slave with ID 0. The Exception Response includes function code 3 and exception code IllegalValue. This issue did not occur prior to the upgrade.

What version of Home Assistant Core has the issue?

core-2025.1.0

What was the last working version of Home Assistant Core?

core-2024.12.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

modbus

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

- name: SmartLogger Active Power
      unique_id: smartLogger_active_power
      unit_of_measurement: W
      device_class: power
      data_type: int32
      address: 40525
      scan_interval: 15
      slave: 0
      input_type: holding
    - name: SmartLogger Input Power
      unique_id: smartLogger_input_power
      unit_of_measurement: W
      device_class: power
      data_type: int32
      address: 40521
      scan_interval: 5
      slave: 0
      input_type: holding

Anything in the logs that might be useful for us?

2025-01-04 13:43:35.328 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40560 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:43:36.601 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40562 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:43:36.735 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40544 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:43:36.845 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40532 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:44:06.734 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40532 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:44:35.512 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40685 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:44:36.736 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40544 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:44:36.757 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40532 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:45:06.739 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40532 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:45:35.507 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40560 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:45:36.083 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40564 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:45:36.734 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40544 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:45:36.754 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40532 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:46:05.559 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40685 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:46:06.741 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40532 -> Exception Response(131, 3, IllegalValue)
2025-01-04 13:46:36.735 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: huaweismartlogger: Error: device: 0 address: 40544 -> Exception Response(131, 3, IllegalValue)

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

I understand that for modbus rtu, the ID 0 is/can be used for broadcast write-messages as the slaves can’t be interrogated/answering all at once.

For modbus tcp, the connection is already unilateral and broadcast is not relevant. So ID 0 can be used to read and write, just like any other ID, because there is only 1 slave anyway on that IP.

Of course, if the IP module is a gateway, for other slaves connected to it, then we are in the situation as with rtu.

So I believe that modbus tcp should again be able/allowed to communicate using ID 0. For rtu, I agree that this is not needed/wanted.

I had the opportunity to spend some time investigating about the problem of the slave id = 0 and I probably found the real reason. I’m testing a fix.

My previous comment is not correct.

Uhm…

2025-01-12 10:25:05.257 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1
2025-01-12 10:25:05.257 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x1 0x0 0x0 0x0 0x6 **0x1** 0x3 0x7d 0x40 0x0 0x2
2025-01-12 10:25:10.261 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1
2025-01-12 10:25:10.262 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x1 0x0 0x0 0x0 0x6 **0x1** 0x3 0x7d 0x40 0x0 0x2
2025-01-12 10:25:15.265 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1
2025-01-12 10:25:15.265 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x1 0x0 0x0 0x0 0x6 **0x1** 0x3 0x7d 0x40 0x0 0x2
2025-01-12 10:25:20.268 DEBUG (MainThread) [pymodbus.logging] Adding transaction 1
2025-01-12 10:25:20.269 DEBUG (MainThread) [pymodbus.logging] send: 0x0 0x1 0x0 0x0 0x0 0x6 **0x1** 0x3 0x7d 0x40 0x0 0x2
2025-01-12 10:25:25.271 ERROR (MainThread) [pymodbus.logging] No response received after 3 retries, continue with next request
2025-01-12 10:25:25.272 ERROR (MainThread) [homeassistant.components.modbus.modbus] Pymodbus: pvsolar: Error: device: 0 address: 32064 -> Exception Response(131, 3, None)

The communication is going to slave 1.

@crug80

Thanks again for the in depth explanation.

Please find the relevant logs for ID 0 in the attachment.

home-assistant_modbus_2025-01-12T09-29-03.514Z.log

Using the dongle I had following remark since yesterday ::

Logger: homeassistant.components.modbus.modbus Source: components/modbus/modbus.py:300 integration: Modbus (documentation, issues) First occurred: 03:56:05 (2 occurrences) Last logged: 09:18:58

Pymodbus: pvsolar: Error: device: 2 address: 37121 -> Exception Response(131, 3, SlaveBusy) Pymodbus: pvsolar: Error: device: 2 address: 37119 -> Exception Response(131, 3, SlaveBusy)

I believe this happens when the dongle is sending/receiving data from the cloud. Unfortunately, when the connection with the cloud is lost, the dongle will continuously try to connect and is always ‘busy’… So I have to allow him to be connected to the cloud of Huawei (which I don’t really like, even though its a EU server)

The connection with the inverters AP (using ID 0) didn’t have those issues.

If Huawei isn’t respecting the official modbus protocol, HA doesn’t need to follow them. And I will use the dongle with ID 2… with the downside to lose connection once a while and have huawei looking over my shoulder.

But if there is a possibility to make ID 0 working again, I would be very grateful.

Regards

@crug80

Thank you clarifying the new implemented approach.

The Huawei Solar Inverter provides Modbus TCP in 2 ways ::

  • Directly via its AP on Port 6607 with ID 0 (not configurable)
  • Using its network dongle on Port 502 with ID 2, in my case (automatically distributed by the inverter)

Indeed, if I now connect to the inverter via the dongle on 502 with ID 2, I get data. Direct connection with its AP on 6607 with ID 0 is not working anymore.

With 2025.1 this broadcast feature (ID 0) is removed. I wonder why it needed to be removed ? I understand to change the default to ID 1, but the modbus broadcast feature is still needed in some cases. Maybe a parameter can be introduced to enable it ?

I’m raising this issu because the connection to the inverter via the dongle is very unstable with a lot of dropped packages (even with message_wait_milliseconds: 6000 and timeout: 5)

I hope that the broadcast feature with ID 0 could still be reintroduced in future updates.

Thank you and All who are contributing in making HA a wonderfull thing for Dummies like myself.

I can confirm, my problem was the slave id 0, I manage to change it on the device to id 7, and it’s working.

Unfortunately, I can’t change this in the wallbox. So I need a fix for the problem

Same issue here. Update to 2025.1.0 crash my modbus. (victron)

I believe I am having somewhat of a similar issue with a custom modbus integration.

All of a sudden after installing 2025.1.0 my sensors are no longer working.

modbus:

  • name: Sungrow SG5.0RS type: tcp host: !secret sungrow_modbus_host_ip port: !secret sungrow_modbus_port sensors:
    • name: Inverter Device Type Code unique_id: inverter_device_type_code device_address: !secret sungrow_modbus_slave address: 4999 # reg 5000 input_type: input data_type: uint16 scan_interval: 1200