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
72.49k stars 30.33k forks source link

Velbus entities became "unavailable" #122161

Closed gurtjun closed 2 months ago

gurtjun commented 2 months ago

The problem

We're using the Velbus integration in our Home Assistant setup for quite a while now and until last week everything was working flawlessly. After a brief power outage all the Velbus entities became "unavailable" in Home Assistant.

We have two VMB1USB devices connected to our Velbus setup. One connected to a Raspberry Pi (running openHAB) and one connected to a NUC (running Home Assistant). Within openHAB everything is still working. We can also see /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00 (device path /dev/ttyACM0) connected in Home Assistant.

A few minutes after restarting the integration we always see

Logger: homeassistant
Source: runner.py:148
First occurred: 9:56:23 AM (1 occurrences)
Last logged: 9:56:23 AM

Error doing job: Task was destroyed but it is pending! (<Task pending name='Task-146' coro=<VelbusProtocol._get_message_from_send_queue() running at /usr/local/lib/python3.12/site-packages/velbusaio/protocol.py:183> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[VelbusProtocol.restart_writing.<locals>.<lambda>() at /usr/local/lib/python3.12/site-packages/velbusaio/protocol.py:75]>)

From what we can see int he logs a connection is established and Home Assistant is constantly receiving data from Velbus itself.

Things we tried so far:

Before removing the integration and adding it from scratch we wanted to check here if someone experienced the same issue before?

What version of Home Assistant Core has the issue?

core-2024.7.2

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

velbus

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-07-19 09:55:41.984 INFO (MainThread) [velbus-protocol] Connection established to Velbus
2024-07-19 09:55:41.984 DEBUG (MainThread) [velbus-protocol] Starting Velbus write message from send queue
2024-07-19 09:55:41.984 DEBUG (MainThread) [velbus-protocol] Acquiring write lock
2024-07-19 09:55:41.987 INFO (MainThread) [velbus-handler] Start module scan
2024-07-19 09:55:41.987 INFO (MainThread) [velbus-handler] Starting handling scan 1
2024-07-19 09:55:41.988 INFO (MainThread) [velbus-handler] Starting scan 1
2024-07-19 09:55:42.000 DEBUG (MainThread) [velbus-protocol] Received 13 bytes from Velbus: b'0f fb 01 07 ff 10 94 7c 00 13 27 95 04'
2024-07-19 09:55:42.001 DEBUG (MainThread) [velbus-handler] Module 1 detected: start loading
2024-07-19 09:55:42.004 INFO (MainThread) [velbus-module] Request module status 1
2024-07-19 09:55:42.062 DEBUG (MainThread) [velbus-protocol] Received 10 bytes from Velbus: b'0f fb 01 04 fe 00 e3 ff 11 04'
2024-07-19 09:55:42.062 DEBUG (MainThread) [velbus-module] RX: {"name": "MemoryDataMessage", "priority": 251, "address": 1, "rtr": false, "data": 255, "high_address": 0, "low_address": 227}
2024-07-19 09:55:42.123 DEBUG (MainThread) [velbus-protocol] Received 10 bytes from Velbus: b'0f fb 01 04 fe 00 e4 ff 10 04'
2024-07-19 09:55:42.123 DEBUG (MainThread) [velbus-module] RX: {"name": "MemoryDataMessage", "priority": 251, "address": 1, "rtr": false, "data": 255, "high_address": 0, "low_address": 228}
2024-07-19 09:55:42.183 DEBUG (MainThread) [velbus-protocol] Received 10 bytes from Velbus: b'0f fb 01 04 fe 00 e5 ff 0f 04'
2024-07-19 09:55:42.184 DEBUG (MainThread) [velbus-module] RX: {"name": "MemoryDataMessage", "priority": 251, "address": 1, "rtr": false, "data": 255, "high_address": 0, "low_address": 229}

Additional information

No response

home-assistant[bot] commented 2 months ago

Hey there @cereal2nd, @brefra, mind taking a look at this issue as it has been labeled with an integration (velbus) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `velbus` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign velbus` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


velbus documentation velbus source (message by IssueLinks)

Cereal2nd commented 2 months ago

from what release did you upgrade? how long did you wait? after the startup of hass? The initial loading can be really slow ...

gurtjun commented 2 months ago

from what release did you upgrade? how long did you wait? after the startup of hass? The initial loading can be really slow ...

We were previously running 2024.7.1 and upgraded last week. Power outage was 2 days and 12 hours ago. The initial loading has always been slow for us. But normally after 5-15 minutes everything should be OK. But yesterday evening we did a restart and this morning the entities were still "unavailable".

Cereal2nd commented 2 months ago

can you try the following?

gurtjun commented 2 months ago

can you try the following?

  • remove the integration
  • clear the cache dir
  • re-add the integration

Removed integration and cleared cache but now we're unable to setup the integration again.

Logger: homeassistant.config_entries
Source: config_entries.py:586
First occurred: 12:08:07 PM (1 occurrences)
Last logged: 12:08:07 PM

Error setting up entry velbus for velbus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/velbus/__init__.py", line 86, in async_setup_entry
    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2059, in async_forward_entry_setups
    await self._async_forward_entry_setups_locked(entry, platforms)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2070, in _async_forward_entry_setups_locked
    await asyncio.gather(
asyncio.exceptions.CancelledError

Also manually filled in the connection string (/dev/ttyACM0).

Should we try to restore the backup of 2024.7.1?

gurtjun commented 2 months ago

can you try the following?

  • remove the integration
  • clear the cache dir
  • re-add the integration

Removed integration and cleared cache but now we're unable to setup the integration again.

Logger: homeassistant.config_entries
Source: config_entries.py:586
First occurred: 12:08:07 PM (1 occurrences)
Last logged: 12:08:07 PM

Error setting up entry velbus for velbus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/velbus/__init__.py", line 86, in async_setup_entry
    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2059, in async_forward_entry_setups
    await self._async_forward_entry_setups_locked(entry, platforms)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2070, in _async_forward_entry_setups_locked
    await asyncio.gather(
asyncio.exceptions.CancelledError

Also manually filled in the connection string (/dev/ttyACM0).

Should we try to restore the backup of 2024.7.1?

Should have waited a bit longer... It seems that it found the entities and they are working after removing and re-adding the integration!

gurtjun commented 2 months ago

can you try the following?

  • remove the integration
  • clear the cache dir
  • re-add the integration

Removed integration and cleared cache but now we're unable to setup the integration again.

Logger: homeassistant.config_entries
Source: config_entries.py:586
First occurred: 12:08:07 PM (1 occurrences)
Last logged: 12:08:07 PM

Error setting up entry velbus for velbus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/velbus/__init__.py", line 86, in async_setup_entry
    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2059, in async_forward_entry_setups
    await self._async_forward_entry_setups_locked(entry, platforms)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2070, in _async_forward_entry_setups_locked
    await asyncio.gather(
asyncio.exceptions.CancelledError

Also manually filled in the connection string (/dev/ttyACM0). Should we try to restore the backup of 2024.7.1?

Should have waited a bit longer... It seems that it found the entities and they are working after removing and re-adding the integration!

But after a restart of HASS the integration disappeared 🤔

gurtjun commented 2 months ago

In the meantime I was able to re-add the integration and everything seems to be working now. Also did the update to 2024.7.3 this morning and it still works.

Closing the issue for now, thanks!

ndemoreau commented 2 months ago

Hi, I'm having the same issue. I moved my homassistant installation from one machine to another one.

Everything works well but the Velbus modules.

If I re-add, I'm scared to loose all my home assistant settings. Did you have the issue or did it recreate everything correctly?