-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove BackBox objects from device registry, special-case parent rela…
…tionship
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Migration functions for the Vantage integration.""" | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.core import HomeAssistant | ||
from homeassistant.helpers import device_registry as dr | ||
|
||
from .const import LOGGER | ||
|
||
|
||
async def async_migrate_data(hass: HomeAssistant, entry: ConfigEntry) -> None: | ||
"""Run all Vantage data migrations.""" | ||
|
||
async_delete_back_boxes(hass, entry) | ||
|
||
|
||
def async_delete_back_boxes(hass: HomeAssistant, entry: ConfigEntry) -> None: | ||
"""Delete back boxes from the device registry.""" | ||
dev_reg = dr.async_get(hass) | ||
|
||
back_box_devices = [ | ||
device | ||
for device in dr.async_entries_for_config_entry(dev_reg, entry.entry_id) | ||
if device.model == "BackBox" | ||
] | ||
|
||
if back_box_devices: | ||
LOGGER.debug(f"Deleting {len(back_box_devices)} back boxes from the registry.") | ||
|
||
for device in back_box_devices: | ||
dev_reg.async_remove_device(device.id) |