Modbus Failure after installing 2022.4

Hi,
after installing 2022.4 I can’t read my modbus energy meters anymore. The log tells me:

Logger: homeassistant.components.modbus.base_platform
Source: components/modbus/base_platform.py:178
Integration: Modbus ([documentation](https://www.home-assistant.io/integrations/modbus), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+modbus%22))
First occurred: 11:44:20 (276 occurrences)
Last logged: 11:49:52

Received 4 bytes, unpack error unpack requires a buffer of 2 bytes

Has anything changed in this release? I’am happy for every advice.

Thanks a lot
Georg

Read the 2022.4.1 release notes.

have a look here and here

Hi,
thank you for your Answers. So I have a direction to look for.
I Don’t unterstand at the moment where I have to change the data types. My Config looks like:

modbus:
  - name: hub1
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: E
    sensors:
      - name: strom_leistung_wohnung
        unit_of_measurement: W
        slave: 114
        address: 0
        count: 2
        scale: 0.1

Can you help my where I have to change?

Thanks in Advance

int, uint & float have been depreciated, check in your configuration.yaml file for sensors under your modbus section that has these and change them to int16, uint16 & float16

Previously int, uint & float were silently converted to int16, uint16 & float16 but now you’ll need to manually change them as they have been depreciated.

If you’re still not sure post your full configuration.yaml file (or at least the entire modbus section) and I’ll try help you.

Backup your configuration.yaml file before hand just in case.

Here is an example from my configuration.yaml file

      - name: "ESS Minimum SOC"
        data_type: uint16    #previously uint
        slave: 100
        address: 2901
        scale: 0.1
      - name: "Victron VEBus Input Power 1"
        data_type: int16    #previously int
        slave: 242
        address: 12
        scale: 10
        unit_of_measurement: "W"
        device_class: power       
1 Like

Thank you for your support.
my config looks actually like this:

modbus:
  - name: hub1
    type: serial
    method: rtu
    port: /dev/ttyUSB0
    baudrate: 9600
    stopbits: 1
    bytesize: 8
    parity: E
    sensors:
      - name: strom_leistung_wohnung
        unit_of_measurement: W
        slave: 114
        address: 0
        count: 2
        scale: 0.1
      - name: strom_menge_wohnung_raw
        unit_of_measurement: kWh
        slave: 114
        address: 16384
        count: 2      
      - name: strom_leistung_haus
        unit_of_measurement: W
        slave: 115
        address: 0
        count: 2
        scale: 0.1
      - name: strom_menge_haus_raw
        unit_of_measurement: kWh
        slave: 115
        address: 16384
        count: 2      
      - name: strom_leistung_bezug_gesamt
        unit_of_measurement: W
        slave: 106
        address: 0
        count: 2
        scale: 0.1
      - name: strom_menge_bezug_gesamt_raw
        unit_of_measurement: kWh
        slave: 106
        address: 16384
        count: 2      
      - name: strom_leistung_einspeisung_gesamt
        unit_of_measurement: W
        slave: 106
        address: 2
        count: 2
        scale: 0.1
      - name: strom_menge_einspeisung_gesamt_raw
        unit_of_measurement: kWh
        slave: 106
        address: 16640
        count: 2      
      - name: strom_leistung_bezug_pv
        unit_of_measurement: W
        slave: 113
        address: 0
        #count: 2
        scale: 0.1
      - name: strom_menge_bezug_pv_raw
        unit_of_measurement: kWh
        slave: 113
        address: 16384
        count: 2      
      - name: strom_leistung_einspeisung_pv
        unit_of_measurement: W
        slave: 113
        address: 2
        count: 2
        scale: 0.1
      - name: strom_menge_einspeisung_pv_raw
        unit_of_measurement: kWh
        slave: 113
        address: 16640
        count: 2  

mmmh, I don’t see int, uint or float in any of those may be somewhere else in your configuration.yaml file.

Do a search in the file for int, uint & float and change them to int16, uint16 & float16 and see if that helps (you’ll need to restart home assistant)

Check your configuration first to make sure there are no errors before restarting.

Also, only do this for sensors under the modbus section

Hi,
The only Place where I use those is

- platform: template
    sensors:

 strom_menge_wohnung:
        value_template: "{{ '%.2f' | format(states('sensor.strom_menge_wohnung_raw') | float / 1000) }}"
        friendly_name: 'Wohnung'
        unit_of_measurement: 'kWh'  
        device_class: 'energy'
        attribute_templates:
          state_class: total_increasing

But as I unterstand this is irrelevant. Right?

Yes as far as I understand it wouldn’t be that.

Not sure what else to suggest, hopefully someone else comes along and can shed some light on the matter.

I am not that much into modbus, but a change from int to int32 might be related to the count in your configuration, since a count of 2 and a bytesize of 8 gives 16, which is equal to int.
Just a guess though

  data_type: int32

Sounds Like an idea. Do you have a Suggestion What to change?

Add data_type to all sensors

“count: 2” is int32 or uint32

Awesome. Thank you all. It works now !

1 Like