mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Remove the Delete button on the ZwaveJS device page (#146544)
This commit is contained in:
parent
43797c03cc
commit
1f221712a2
@ -1119,38 +1119,6 @@ async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
|||||||
LOGGER.error(err)
|
LOGGER.error(err)
|
||||||
|
|
||||||
|
|
||||||
async def async_remove_config_entry_device(
|
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry
|
|
||||||
) -> bool:
|
|
||||||
"""Remove a config entry from a device."""
|
|
||||||
client: ZwaveClient = config_entry.runtime_data[DATA_CLIENT]
|
|
||||||
|
|
||||||
# Driver may not be ready yet so we can't allow users to remove a device since
|
|
||||||
# we need to check if the device is still known to the controller
|
|
||||||
if (driver := client.driver) is None:
|
|
||||||
LOGGER.error("Driver for %s is not ready", config_entry.title)
|
|
||||||
return False
|
|
||||||
|
|
||||||
# If a node is found on the controller that matches the hardware based identifier
|
|
||||||
# on the device, prevent the device from being removed.
|
|
||||||
if next(
|
|
||||||
(
|
|
||||||
node
|
|
||||||
for node in driver.controller.nodes.values()
|
|
||||||
if get_device_id_ext(driver, node) in device_entry.identifiers
|
|
||||||
),
|
|
||||||
None,
|
|
||||||
):
|
|
||||||
return False
|
|
||||||
|
|
||||||
controller_events: ControllerEvents = config_entry.runtime_data[
|
|
||||||
DATA_DRIVER_EVENTS
|
|
||||||
].controller_events
|
|
||||||
controller_events.registered_unique_ids.pop(device_entry.id, None)
|
|
||||||
controller_events.discovered_value_ids.pop(device_entry.id, None)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_ensure_addon_running(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
async def async_ensure_addon_running(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Ensure that Z-Wave JS add-on is installed and running."""
|
"""Ensure that Z-Wave JS add-on is installed and running."""
|
||||||
addon_manager = _get_addon_manager(hass)
|
addon_manager = _get_addon_manager(hass)
|
||||||
|
@ -1692,27 +1692,6 @@ async def test_replace_different_node(
|
|||||||
(DOMAIN, multisensor_6_device_id_ext),
|
(DOMAIN, multisensor_6_device_id_ext),
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_client = await hass_ws_client(hass)
|
|
||||||
|
|
||||||
# Simulate the driver not being ready to ensure that the device removal handler
|
|
||||||
# does not crash
|
|
||||||
driver = client.driver
|
|
||||||
client.driver = None
|
|
||||||
|
|
||||||
response = await ws_client.remove_device(hank_device.id, integration.entry_id)
|
|
||||||
assert not response["success"]
|
|
||||||
|
|
||||||
client.driver = driver
|
|
||||||
|
|
||||||
# Attempting to remove the hank device should pass, but removing the multisensor should not
|
|
||||||
response = await ws_client.remove_device(hank_device.id, integration.entry_id)
|
|
||||||
assert response["success"]
|
|
||||||
|
|
||||||
response = await ws_client.remove_device(
|
|
||||||
multisensor_6_device.id, integration.entry_id
|
|
||||||
)
|
|
||||||
assert not response["success"]
|
|
||||||
|
|
||||||
|
|
||||||
async def test_node_model_change(
|
async def test_node_model_change(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user