Vaskivskyi / ha-asusrouter

Monitor and control your AsusWRT-powered router from Home Assistant
https://asusrouter.vaskivskyi.com
Apache License 2.0
184 stars 17 forks source link

AsusRouter Integration doesn't reload automatically upon HA reboot [Bug] #841

Open bfish2 opened 4 months ago

bfish2 commented 4 months ago

The problem

For the past several months, when I have restarted HA, I have had to manually press reload on the entries for each AP in the integration in order to get it to fully load. More recently (past few weeks), I have had to press reload many times (up to 10 or more) on each entry in order to get them to fully load. Once loaded, the integration seems to be working OK.

Your device model

RT-AX92U

Firmware type

Stock

Firmware version

3.0.0.4.388_23630

Integration version with the issue

0.32.1

Method of the integration installation

HACS

What version and type of Home Assistant installation do you use

Core 20242.6.3

Is there anything useful in the logs?

Logger: homeassistant.config_entries
Source: config_entries.py:594
First occurred: 8:17:01 AM (12 occurrences)
Last logged: 8:24:22 AM

Error setting up entry 192.168.86.1 for asusrouter
Error setting up entry 192.168.86.249 for asusrouter
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/asusrouter/__init__.py", line 27, in async_setup_entry
    await router.setup()
  File "/config/custom_components/asusrouter/router.py", line 363, in setup
    device_registry.async_remove_device(device_entry.id)
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 947, in async_remove_device
    device = self.devices.pop(device_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen _collections_abc>", line 951, in pop
  File "/usr/src/homeassistant/homeassistant/helpers/registry.py", line 62, in __delitem__
    self._unindex_entry(key)
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 543, in _unindex_entry
    super()._unindex_entry(key, replacement_entry)
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 484, in _unindex_entry
    del self._identifiers[identifier]
        ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: ('asusrouter', '04:42:1a:6a:2d:20')

Diagnostics information

syslog.txt

Additional information

No response

Vaskivskyi commented 4 months ago

Hello, @bfish2. Thanks for your feedback and sorry for the issues you are experiencing. I will check this

yuejon commented 4 months ago

I also have this issue and my workaround has been to use an automation which loops and reloads the config until the integration is back online, whenever HA is restarted. Definitely would prefer a permanent fix in the integration itself, but this workaround at least lets me not have to constantly reload it manually after a restart.

alias: "Network: Reload AsusRouter integration on start"
description: ""
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - alias: Reload Asus ZenWiFi Router Config
    repeat:
      sequence:
        - service: homeassistant.reload_config_entry
          data: {}
          target:
            entity_id: sensor.asus_zenwifi_boot_time
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
      while:
        - condition: and
          conditions:
            - condition: state
              entity_id: sensor.asus_zenwifi_boot_time
              state: unavailable
mode: single
matt0020190 commented 2 months ago

Hi, just to report I have exactly the same issue. Eventually the integration reloads but it takes several attempts. Any update?

bitlisz1 commented 1 month ago

Same issue here with 2 pcs of RT-AX92U, and mesh router unavaiable, always need to reload integration.

micdesa commented 1 month ago

Same here

bitlisz1 commented 1 month ago

Same issue here with 2 pcs of RT-AX92U, and mesh router unavaiable, always need to reload integration.

Sometimes Main router:

Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 10:38:17 AM (1 occurrences)
Last logged: 10:38:17 AM

Error setting up entry 192.168.1.1 for asusrouter
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/asusrouter/__init__.py", line 27, in async_setup_entry
    await router.setup()
  File "/config/custom_components/asusrouter/router.py", line 370, in setup
    device_registry.async_remove_device(device_entry.id)
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1141, in async_remove_device
    device = self.devices.pop(device_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen _collections_abc>", line 951, in pop
  File "/usr/src/homeassistant/homeassistant/helpers/registry.py", line 62, in __delitem__
    self._unindex_entry(key)
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 613, in _unindex_entry
    super()._unindex_entry(key, replacement_entry)
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 554, in _unindex_entry
    del self._identifiers[identifier]
        ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: ('asusrouter', None)
bitlisz1 commented 1 week ago

It is very frequent. Added some debug log (replaced/removed all mac/ip and others).

bitlisz1 commented 1 week ago

home-assistant_2024-10-22T11-23-03.348Z.log