home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.14k stars 29.18k forks source link

Modbus with multiple connections not working #52787

Closed Dutcherik closed 3 years ago

Dutcherik commented 3 years ago

The problem

I have two solar inverters from which I read data with the modbus integration. Before the update of modbus it worked well. You could define from which hub the register / sensor should read (hub: sb25). Now after the update the data I get is from one hub only (the first). So sensor smasb4_power has the same value as smasb2_power (power production in watt).

What is version of Home Assistant Core has the issue?

2021.7.0

What was the last working version of Home Assistant Core?

2021.6.5 (??)

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: sb4000
    host: 192.168.1.10
    port: 502
    type: tcp
    sensors:
    - name: smasb4_netfreq
      scan_interval: 10
      unit_of_measurement: Hz
      slave: 3
      address: 30803
      input_type: input
      count: 2
      data_type: uint
      scale: 0.01
      precision: 2
    - name: smasb4_power
      scan_interval: 10
      unit_of_measurement: W
      slave: 3
      address: 30775
      input_type: input
      count: 2
      data_type: int
      scale: 1
      precision: 0
    - name: smasb4_volt
      scan_interval: 10
      unit_of_measurement: V
      slave: 3
      address: 30783
      input_type: input
      count: 2
      data_type: int
      scale: 0.01
      precision: 0

  - name: sb25
    host: 192.168.1.11
    port: 503
    type: tcp
    sensors:
    - name: smasb2_netfreq
      scan_interval: 10
      unit_of_measurement: Hz
      slave: 3
      address: 30803
      input_type: input
      count: 2
      data_type: uint
      scale: 0.01
      precision: 2
    - name: smasb2_power
      scan_interval: 10
      unit_of_measurement: W
      slave: 3
      address: 30775
      input_type: input
      count: 2
      data_type: int
      scale: 1
      precision: 0
    - name: smasb2_volt
      scan_interval: 10
      unit_of_measurement: V
      slave: 3
      address: 30783
      input_type: input
      count: 2
      data_type: int
      scale: 0.01
      precision: 0

Anything in the logs that might be useful for us?

Nothing in the logs

Additional information

No response

probot-home-assistant[bot] commented 3 years ago

modbus documentation modbus source (message by IssueLinks)

0xa51f commented 3 years ago

https://github.com/home-assistant/core/issues/52765

probot-home-assistant[bot] commented 3 years ago

Hey there @adamchengtkc, @janiversen, @vzahradnik, mind taking a look at this issue as its been labeled with an integration (modbus) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

janiversen commented 3 years ago

At least you have a configuration, that are easy to use, thanks for that. I will try to add your config to a test bench and see if I can reproduce it.

I believe this is a real problem in the integration, I just cannot tell you (yet) where.

lucode commented 3 years ago

Same problem here. Upgrade to 2021.7.1 did not help either. Switched back to core-2021.6.6 where everything works well. Runs on a Raspi P4 with Maria DB and SSD.

In addition, I only have one TCP connection to a Vitron CGGX.

bercht-a commented 3 years ago

Same here with 2021.7.1

nilsvdb82 commented 3 years ago

I have 3 Modbus connections

Nothing found in the logs

janiversen commented 3 years ago

“not working at all” is the same as no information, and no help to find and solve whatever problem there are. If you want your problem solved, you need to actively help.

It is impossible that a debug log (as pr documentation) contains nothing, that means you never configured modbus.

janiversen commented 3 years ago

@lucode how can it be the same problem if you only have one connection, thats not logical, or are you saying that you get data duplicated with one connection?

bthovda commented 3 years ago

Hi. Im having the same issue. I have two ventilation systems in my house. I will try to get some more logs out of my system.

config:


modbus:
      - name: systemair8a
        type: tcp
        host: 192.168.1.36
        port: 5021
        sensors:
            - name: vent8a_actual_fanspeed_modbus
              scan_interval: 8
              address: 100

            - name: vent8a_actual_heatlvl_modbus
              scan_interval: 8
              address: 206

            - name: vent8a_supply_temperature_modbus
              unit_of_measurement: °C
              device_class: temperature
              scan_interval: 60
              address: 213
              scale: 0.1
              precision: 1

      - name: systemair_8b
        type: tcp
        host: 192.168.1.125
        port: 5021
        sensors:
            - name: vent8b_supply_temperature_modbus
              unit_of_measurement: °C
              device_class: temperature
              scan_interval: 8
              address: 213
              scale: 0.1
              precision: 1

            - name: vent8b_actual_heatlvl_modbus
              scan_interval: 8
              address: 206
nilsvdb82 commented 3 years ago

@janiversen Didn't mean any disrespect, just wanted to add a case to the list. The HA logfile (when debug is enabled as per modbus documentation) grows to 14Mb after startup, so did look at it... (too much info makes it irrelevant...)

My config for the 3 entries:

`modbus:

janiversen commented 3 years ago

If you look above there is a patch to solve the problem #52794

lucode commented 3 years ago

@lucode how can it be the same problem if you only have one connection, thats not logical, or are you saying that you get data duplicated with one connection?

Sorry but I'm not good in analyzing log data in HA. It is just what I did experience. Maybe it is due to "close_comm_on_error: true" that I couldn't see logs related to modbus.

# cat modbus.yaml
# configuration entry for a TCP connection
# modbus:
name: victron
close_comm_on_error: true
delay: 5
timeout: 5
type: tcp
host: 192.168.1.7
port: 502

And yes eventually I'm in the wrong thread here, but something did happen to the modbus behaviour between version core-2021.6.6 and 2021.7.1 + 2021.7.1. In my case only 2021.6.6 works.

janiversen commented 3 years ago

Surely you have a problem, but we try hard to only have one problem in one issue, that way the issue in total is easier to control. Look at open issues, there might be another issue that fits your problem, otherwise open a new issue.

You are not expected to analyze the log, I will do that, but you need to supply a debug log (in the proper issue) see documentation on how to activate debug logging.

I am pretty sure that “close_comm_on_error” is a parameter you should not use, this is nearly only usefull when the connection goes via an usb connector.

Dutcherik commented 3 years ago

Thank you janiversen!