core: Writing to Modbus registers stopped working

The problem

At some point of time (unsure if this was due to an update), writing to a modbus register stopped working for me. I don’t use it (writing) often, however for the past week or so I have been trying to write to a modbus register with no success. Writing to the register does not fail or produce an error, it just does not update the register with the new value. I have no problem reading modbus registers and have been able to do so continuously for months already.

I tried different HA installations: HA Supervised, HA OS, different hardware, e.g. Odroid XU4, two different Generic X86-64 machines. The device (a Growatt SPF 5000 ES inverter) is connected via an onboard usb-to-serial device (the underlying chipset is Silicon Lab CP210x).

image

What version of Home Assistant Core has the issue?

2023.5.4

What was the last working version of Home Assistant Core?

No response

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/

Diagnostics information

home-assistant_2023-06-07T09-47-19.107Z.log

Example YAML snippet

odbus:
  - name: Left_Inverter
    type: serial
    port: /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_789195d4659cec11b292654d73138bba-if00-port0
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    stopbits: 1
    delay:  3
    retry_on_empty: true
    # retries: 10
    # close_comm_on_error: true
    message_wait_milliseconds: 1000
    #timeout: 5
    sensors:

      - name: Output source config (Left-Inverter)
        scan_interval: 5
        address: 1
        slave: 1
        input_type: holding
        data_type: int16
        scale: 1
        offset: 0
        precision: 0
        unique_id:  Left_Inverter.OutputSourceConfig
      - name: Charging source config (Left-Inverter)
        scan_interval: 5
        address: 2
        slave: 1
        input_type: holding
        data_type: int16
        scale: 1
        offset: 0
        precision: 0
        unique_id:  Left_Inverter.ChargingSourceConfig        

#Snippet of automation / Service call through Developer Tools
service: modbus.write_register
data:
  hub: Left_Inverter
  address: 1
  slave: 1
  value: [2,0]

Anything in the logs that might be useful for us?

No error messages that I could see...

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@janiversen, /dev/serial/by-id is broken due to a recent Linux update.

you have a problem:

Left_Inverter: Modbus Error: [Connection] Failed to

pymodbus.logging] [Errno 2] could not open port /dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_789195d4659cec11b292654d73138bba-if00-port0: [Errno 2] No such file or directory: ‘/dev/serial/by-id/usb-Silicon_Labs_CP2102N_USB_to_UART_Bridge_Controller_789195d4659cec11b292654d73138bba-if00-port0’ 2023-06-09 17:39:24.035 DEBUG (SyncWorker_3) [homeassistant.components.modbus.modbus]

seems your serial port cannot be opened, this is a problem outside our control.

This continues throughout the log, so you have not read any values, and of course you are also not able to write registers.

Closing this issue as it is a user problem and not a bug in the integration.