schmittx / home-assistant-eero

Eero integration for Home Assistant
MIT License
108 stars 22 forks source link

Deprecation refactor for async_get_registry and async_setup_platforms #47

Closed thayerfox closed 1 year ago

thayerfox commented 1 year ago

Refactor async_get_registry to async_get and async_setup_platforms to async_forward_entry_setups as both methods are deprecated.

Resolved issue #41 and #48 for me.

blizzrdof77 commented 1 year ago

I can confirm that this does fix the issue. @schmittx please approve this PR. Thanks @thayerfox !

michaelthompson1991 commented 1 year ago

Do we need to update anything to fix it? Not sure if it's in HA or HACS updates

pietrouk commented 1 year ago

Thanks @blizzrdof77 and @thayerfox I changed the code as described but I'm still getting an error, can you please help?

This is what I did (step by step for other newbies like me): 1/ Open File editor 2/ Open file /config/custom_components/eero/init.py 3/ In row 149 and 150 replace "await hass.helpers.device_registry.async_get_registry()" with "hass.helpers.device_registry.async_get(hass)" 4/ In row 349 replace "hass.config_entries.async_setup_platforms(entry, PLATFORMS)" with "await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)" 5/ Save file, check configuration and restart Home Assistant

now I'm getting this error:

Logger: homeassistant.config_entries Source: helpers/entity_registry.py:1085 First occurred: 08:33:09 (2 occurrences) Last logged: 08:37:55

Error setting up entry Eero WiFi for eero Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/eero/init.py", line 155, in async_setup_entry for entity_entry in hass.helpers.entity_registry.async_entries_for_device(entity_registry, device_entry.id): File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1085, in async_entries_for_device for entry in registry.entities.values() AttributeError: 'DeviceRegistry' object has no attribute 'entities'

thayerfox commented 1 year ago

Thanks @blizzrdof77 and @thayerfox I changed the code as described but I'm still getting an error, can you please help?

This is what I did (step by step for other newbies like me): 1/ Open File editor 2/ Open file /config/custom_components/eero/init.py 3/ In row 149 and 150 replace "await hass.helpers.device_registry.async_get_registry()" with "hass.helpers.device_registry.async_get(hass)" 4/ In row 349 replace "hass.config_entries.async_setup_platforms(entry, PLATFORMS)" with "await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)" 5/ Save file, check configuration and restart Home Assistant

You did see that line 149 and line 150 were different right?

149: device_registry = hass.helpers.device_registry.async_get(hass) 150: entity_registry = hass.helpers.entity_registry.async_get(hass)

pietrouk commented 1 year ago

oh yeah duh! Thanks @thayerfox all working now

schmittx commented 1 year ago

Addressed in 1.2.0