core: Modbus TCP problems with 2 device since upgrade to core-2021.7.0

The problem

I am experiencing a couple of problems with the modbus TCP integration since upgrade to core-2021.7.0.

I have previously changed to the new modbus yaml config a couple of months back, and it was working perfectly until the upgrade.

I have 2 VenusOS devices - a CCGX and CerboGX

YAML config has CCGX followed by CerboGX

  1. Some sensors on the CCGX are unavailable since upgrade (specifically the ones with different slave/address from the CerboGX

  2. Sensors with the same slave/address are showing the same values (that of the CerboGX)

see attached YAML sample code, CCGX is configured before the CerboGX

So for device victron, sensor.grid_frequency and sensor.battery_voltage are unavailable, but sensor.battery_percentage is the value of sensor.battery_percentage_2 for device victron2 (and the correct value)

victron2 device sensors sensor.griod_frequency_2 and sensor.battery_voltage_2 are correct.

I hope i have explained my problem clearly

modbus debug logs attached

What is version of Home Assistant Core has the issue?

core-2021.7.0

What was the last working version of Home Assistant Core?

core-2021.6.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

modbus

Link to integration documentation on our website

https://www.home-assistant.io/integrations/modbus/

Example YAML snippet

modbus:
  - name: victron
    type: tcp
    host: 172.X.X.X
    port: 502
    sensors:
      - name: Grid Frequency
        unit_of_measurement: "Hz"
        device_class: power
        slave: 246
        address: 9
        scale: 0.01
      - name: Battery Voltage
        unit_of_measurement: "V DC"
        device_class: power
        slave: 245
        address: 259
        scale: 0.01
        precision: 2
      - name: Battery Percentage
        unit_of_measurement: "%"
        device_class: battery
        slave: 100
        precision: 2
        address: 843

  - name: victron2
    type: tcp
    host: 192.168.X.X
    port: 502
    sensors:
      - name: Grid Frequency_2
        unit_of_measurement: "Hz"
        device_class: power
        slave: 227
        address: 9
        scale: 0.01
      - name: Battery Voltage_2
        unit_of_measurement: "V DC"
        device_class: power
        slave: 225
        address: 259
        scale: 0.01
        precision: 2
      - name: Battery Percentage_2
        unit_of_measurement: "%"
        device_class: battery
        slave: 100
        precision: 2
        address: 843

Anything in the logs that might be useful for us?

2021-07-08 07:42:05 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/modbus/sensor.py", line 113, in async_update
    result = await self._hub.async_pymodbus_call(
  File "/usr/src/homeassistant/homeassistant/components/modbus/modbus.py", line 313, in async_pymodbus_call
    if not self._client.is_socket_open():
AttributeError: 'NoneType' object has no attribute 'is_socket_open'
2021-07-08 07:42:05 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/modbus/sensor.py", line 113, in async_update
    result = await self._hub.async_pymodbus_call(
  File "/usr/src/homeassistant/homeassistant/components/modbus/modbus.py", line 313, in async_pymodbus_call
    if not self._client.is_socket_open():
AttributeError: 'NoneType' object has no attribute 'is_socket_open'

2021-07-08 07:42:46 ERROR (SyncWorker_6) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_6) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_17) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_0) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_8) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_14) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_6) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:46 DEBUG (SyncWorker_6) [homeassistant.components.modbus.modbus] Pymodbus: Exception Response(131, 3, GatewayPathUnavailable)
2021-07-08 07:42:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2021-07-08 07:42:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2021-07-08 07:42:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
2021-07-08 07:42:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
2021-07-08 07:42:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2021-07-08 07:42:53 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 17 (4 by maintainers)

Most upvoted comments

@frenck i think this issue needs to be re-opened, or see #52765, which seems to be the same

@asifkassam @janiversen Yes, I seem to have the same issue as listed in #52765

I have not done a debug yet if that would help I can, Just let me know how I can help in anyway to assist and sort out as I am now stuck and cannot move as my Solar is an intergral part of my Home Automation setup

Cheers

This seems to be another error, please file a new issue, and please add debug logs, that show what happens when you swap X1Slave and X1Master.

When I swap them around, the sensor reading of x1master that was for both become the readings of x1slave for both

I have reverted back to 20.21.6.6 and with no change to my yaml structure both x1slave and x1master show the correct readings

x1master has pv panles & battery connected x1slave has no panels but does have batteries connected

under 2021.6.6: x1master show the power from the panles, battery charge/discharge power and its remaining capacity x1slave shows 0w from the panles but does show the battery charge/discharge power and its remaining capacity

The reading are as expected per inverter

under 2021.7.0: with x1slave first x1master shows the wattage from the panles, battery power and its capacity x1slave shows the exact same figures from panels battery power and its capacity as x1master

under 2021.7.0: with x1master first x1master shows zero wattage from the panles but shows the battery power and its capacity from x1slave x1slave shows the wattage from the panles, battery power and its capacity

I have matched the readings by looking at the inverter app directly so know that they are reporting wrong no matte which is first under 2021.7.0

After reverting to 2021.6.6 its all back as it should be