RobertD502 / home-assistant-petkit

Home Assistant integration for PetKit devices
MIT License
155 stars 24 forks source link

Unable to delete old device #74

Open yieldhog opened 1 week ago

yieldhog commented 1 week ago

Hi--

Great integration, have been using it since your beta tests. I recently upgraded my Pura X to the Pura Max litter box. I deleted the old device (Pura X) from the official PetKit app under my account, however, it continues to show up in the integration after rebooting and reloading the integration.

I can disable the device, but, is there a way to cleanly delete it from Home Assistant? Thanks

RobertD502 commented 1 week ago

Thanks for bringing that to my attention. At the moment, no. I will have to add a function for removing a device manually. It is implemented for an entire config entry, but currently missing for individual devices.

yieldhog commented 1 week ago

Cool, I wish I had the ability to help you out there -- but, happy to help you test when you have time. Thank you

RobertD502 commented 1 week ago
  1. Open the __init__.py file in custom_components/petkit.
  2. Under the line from homeassistant.core import HomeAssistant add this new line: from homeassistant.helpers import device_registry as dr
  3. At the very end of the file, add the following function:
async def async_remove_config_entry_device(
    hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry
) -> bool:
    """Remove a config entry from a device."""
    return True

Save the changes and restart Home Assistant. You should now see a delete button when you click on the Pura X device.

yieldhog commented 1 week ago

Nice, that worked thank you!