Change SkyConnect integration type back to `hardware` and fix multi-PAN migration bug (#116474)

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
puddly 2024-04-30 16:47:17 -04:00 committed by GitHub
parent 1641df18ce
commit 963d8d6a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 54 additions and 6 deletions

View File

@ -597,6 +597,21 @@ class HomeAssistantSkyConnectMultiPanOptionsFlowHandler(
"""Return the name of the hardware."""
return self._hw_variant.full_name
async def async_step_flashing_complete(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Finish flashing and update the config entry."""
self.hass.config_entries.async_update_entry(
entry=self.config_entry,
data={
**self.config_entry.data,
"firmware": ApplicationType.EZSP.value,
},
options=self.config_entry.options,
)
return await super().async_step_flashing_complete(user_input)
class HomeAssistantSkyConnectOptionsFlowHandler(
BaseFirmwareInstallFlow, OptionsFlowWithConfigEntry

View File

@ -5,7 +5,7 @@
"config_flow": true,
"dependencies": ["hardware", "usb", "homeassistant_hardware"],
"documentation": "https://www.home-assistant.io/integrations/homeassistant_sky_connect",
"integration_type": "device",
"integration_type": "hardware",
"usb": [
{
"vid": "10C4",

View File

@ -2565,11 +2565,6 @@
"integration_type": "virtual",
"supported_by": "netatmo"
},
"homeassistant_sky_connect": {
"name": "Home Assistant SkyConnect",
"integration_type": "device",
"config_flow": true
},
"homematic": {
"name": "Homematic",
"integrations": {

View File

@ -11,6 +11,8 @@ from universal_silabs_flasher.const import ApplicationType
from homeassistant.components import usb
from homeassistant.components.hassio.addon_manager import AddonInfo, AddonState
from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon import (
CONF_DISABLE_MULTI_PAN,
get_flasher_addon_manager,
get_multiprotocol_addon_manager,
)
from homeassistant.components.homeassistant_sky_connect.config_flow import (
@ -869,11 +871,25 @@ async def test_options_flow_multipan_uninstall(
version="1.0.0",
)
mock_flasher_manager = Mock(spec_set=get_flasher_addon_manager(hass))
mock_flasher_manager.async_get_addon_info.return_value = AddonInfo(
available=True,
hostname=None,
options={},
state=AddonState.NOT_RUNNING,
update_available=False,
version="1.0.0",
)
with (
patch(
"homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.get_multiprotocol_addon_manager",
return_value=mock_multipan_manager,
),
patch(
"homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.get_flasher_addon_manager",
return_value=mock_flasher_manager,
),
patch(
"homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon.is_hassio",
return_value=True,
@ -883,3 +899,25 @@ async def test_options_flow_multipan_uninstall(
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "addon_menu"
assert "uninstall_addon" in result["menu_options"]
# Pick the uninstall option
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={"next_step_id": "uninstall_addon"},
)
# Check the box
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_DISABLE_MULTI_PAN: True}
)
# Finish the flow
result = await hass.config_entries.options.async_configure(result["flow_id"])
await hass.async_block_till_done(wait_background_tasks=True)
result = await hass.config_entries.options.async_configure(result["flow_id"])
await hass.async_block_till_done(wait_background_tasks=True)
result = await hass.config_entries.options.async_configure(result["flow_id"])
assert result["type"] is FlowResultType.CREATE_ENTRY
# We've reverted the firmware back to Zigbee
assert config_entry.data["firmware"] == "ezsp"