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.56k stars 29.48k forks source link

Modbus sensors go unavailable after `modbus.reload` #75100

Closed bjeanes closed 1 year ago

bjeanes commented 2 years ago

The problem

Calling modbus.reload service (or hitting Modbus under YAML Reloading in dev tools) does not re-open the modbus connection.

Further, modbus.restart does not work after having called reload (but does prior).

I have tested this on a local dev container after discovering it on my own installation (running 2022.7.3), so this exists in main as of today.

Likely related to #68161

What version of Home Assistant Core has the issue?

2022.8.0.dev0

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

There is no integration which shows up in UI when using Modbus as far as I can tell.

The logs show these two lines when running the service:

2022-07-13 01:50:31.842 INFO (MainThread) [homeassistant.components.modbus] Modbus reloading
2022-07-13 01:50:35.603 WARNING (MainThread) [homeassistant.components.modbus.modbus] modbus Sungrow communication closed

Subsequent calls just output:

2022-07-13 01:56:36.446 INFO (MainThread) [homeassistant.components.modbus] Modbus reloading

Example YAML snippet

modbus:
  - name: SungrowInverter
    type: tcp
    host: !secret solar_inverter_ip
    port: 502
    sensors: # address is -1 from the documented register
      - name: Inverter PV Power
        slave: 1
        address: 5016 # 5017
        input_type: input
        count: 2
        data_type: uint32
        swap: word
        precision: 0
        unit_of_measurement: W
        device_class: power
        state_class: measurement
        scale: 1
        scan_interval: 10

Anything in the logs that might be useful for us?

No response

Additional information

No response

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

modbus documentation modbus source (message by IssueLinks)

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

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

go2sh commented 2 years ago

I can confirm that with a current installation. Only a complete restart works.

SenorRodriguez commented 2 years ago

Bump. Same here.

janiversen commented 1 year ago

I will get around to looking at it soon.

lausitzer commented 1 year ago

Same here on 2022.10.3 (Docker).

janiversen commented 1 year ago

Yes it is still on my list. I am working hard on the underlaying library to make the connections a lot stabler.

janiversen commented 1 year ago

Fixed in #82253 and a duplicate of #82142

Closing.