gluap / pyduofern-hacs

Repository managing hacs-integration for pyduofern
MIT License
27 stars 8 forks source link

Removing devices from HA registry fails #44

Closed bcutter closed 11 months ago

bcutter commented 11 months ago

Tried the delete feature of https://github.com/gluap/pyduofern-hacs/releases/tag/v0.5.11 with my two ghost devices (following up on #36):

grafik

After deletion, nothing happens. Device stays in HA registry.

Getting two issues in HA log (please note: tried deleting one / the same device twice):

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/duofern/__init__.py:58
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 16:53:04 (2 occurrences)
Last logged: 16:55:11

[545929788096] Error handling message: Unknown error (unknown_error) %username% from xxx.xxx.xxx.xxx (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0)
[545932705072] Error handling message: Unknown error (unknown_error) %username% from xxx.xxx.xxx.xxx (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0)
Traceback (most recent call last):
  File "/config/custom_components/duofern/__init__.py", line 54, in async_remove_config_entry_device
    del (stick.duofern_parser.modules["by_code"][device_entry.name])
KeyError: '416415'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/config/device_registry.py", line 131, in websocket_remove_config_entry_from_device
    if not await component.async_remove_config_entry_device(
  File "/config/custom_components/duofern/__init__.py", line 58, in async_remove_config_entry_device
    logging.warning(device_entry.__dict__)
AttributeError: 'DeviceEntry' object has no attribute '__dict__'

and

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: root
Source: custom_components/duofern/__init__.py:57
Integration: Duofern control (documentation, issues)
First occurred: 16:53:04 (2 occurrences)
Last logged: 16:55:11

DeviceEntry(area_id=None, config_entries={'6fbbda39ef703642a9c032480f269e08'}, configuration_url=None, connections=set(), disabled_by=<DeviceEntryDisabler.USER: 'user'>, entry_type=None, hw_version=None, id='61907f529c228e7a1ac2ac1a8683c48b', identifiers={('duofern', '416415')}, manufacturer='Rademacher', model=None, name_by_user='zzzOLD_Non-Existing-NeverExisted-DeleteMe', name='416415', suggested_area=None, sw_version=None, via_device_id=None, is_new=False)

Update:

gluap commented 11 months ago

Ah I see, this must have been a device that was already removed from duofern config (by means of clean_config), I had none of those so didn't test that. Hope it works with 0.5.13

bcutter commented 11 months ago

Yes, v0.5.13 looks much better:

Summary: solved.

Thank you for your quick support on this. Happy new year! šŸŽ‰šŸš€