Skip to content

Commit 1222828

Browse files
authored
Show Z2M docs link in final step of hardware config flow (home-assistant#155736)
1 parent 1ef6458 commit 1222828

File tree

7 files changed

+59
-3
lines changed

7 files changed

+59
-3
lines changed

homeassistant/components/homeassistant_connect_zbt2/strings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
},
6363
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::title%]"
6464
},
65+
"show_z2m_docs_url": {
66+
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::description%]",
67+
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::title%]"
68+
},
6569
"start_otbr_addon": {
6670
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
6771
},
@@ -204,6 +208,10 @@
204208
"reconfigure_addon": {
205209
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::reconfigure_addon::title%]"
206210
},
211+
"show_z2m_docs_url": {
212+
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::description%]",
213+
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::title%]"
214+
},
207215
"start_addon": {
208216
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::start_addon::title%]"
209217
},

homeassistant/components/homeassistant_hardware/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@
3535

3636
SILABS_MULTIPROTOCOL_ADDON_SLUG = "core_silabs_multiprotocol"
3737
SILABS_FLASHER_ADDON_SLUG = "core_silabs_flasher"
38+
39+
Z2M_EMBER_DOCS_URL = "https://www.zigbee2mqtt.io/guide/adapters/emberznet.html"

homeassistant/components/homeassistant_hardware/firmware_config_flow.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from homeassistant.helpers.aiohttp_client import async_get_clientsession
3434
from homeassistant.helpers.hassio import is_hassio
3535

36-
from .const import OTBR_DOMAIN, ZHA_DOMAIN
36+
from .const import OTBR_DOMAIN, Z2M_EMBER_DOCS_URL, ZHA_DOMAIN
3737
from .util import (
3838
ApplicationType,
3939
FirmwareInfo,
@@ -456,7 +456,7 @@ async def async_step_continue_zigbee(
456456
assert self._hardware_name is not None
457457

458458
if self._zigbee_integration == ZigbeeIntegration.OTHER:
459-
return self._async_flow_finished()
459+
return await self.async_step_show_z2m_docs_url()
460460

461461
result = await self.hass.config_entries.flow.async_init(
462462
ZHA_DOMAIN,
@@ -475,6 +475,21 @@ async def async_step_continue_zigbee(
475475
)
476476
return self._continue_zha_flow(result)
477477

478+
async def async_step_show_z2m_docs_url(
479+
self, user_input: dict[str, Any] | None = None
480+
) -> ConfigFlowResult:
481+
"""Show Zigbee2MQTT documentation link."""
482+
if user_input is not None:
483+
return self._async_flow_finished()
484+
485+
return self.async_show_form(
486+
step_id="show_z2m_docs_url",
487+
description_placeholders={
488+
**self._get_translation_placeholders(),
489+
"z2m_docs_url": Z2M_EMBER_DOCS_URL,
490+
},
491+
)
492+
478493
@callback
479494
def _continue_zha_flow(self, zha_result: ConfigFlowResult) -> ConfigFlowResult:
480495
"""Continue the ZHA flow."""

homeassistant/components/homeassistant_hardware/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
},
5454
"title": "Pick your protocol"
5555
},
56+
"show_z2m_docs_url": {
57+
"description": "Your {model} is now running the latest Zigbee firmware.\nPlease read the Zigbee2MQTT documentation for EmberZNet adapters and copy the config for your {model}: {z2m_docs_url}",
58+
"title": "Set up Zigbee2MQTT"
59+
},
5660
"start_otbr_addon": {
5761
"title": "Configuring Thread"
5862
},

homeassistant/components/homeassistant_sky_connect/strings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
},
6363
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::pick_firmware::title%]"
6464
},
65+
"show_z2m_docs_url": {
66+
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::description%]",
67+
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::title%]"
68+
},
6569
"start_otbr_addon": {
6670
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::start_otbr_addon::title%]"
6771
},
@@ -204,6 +208,10 @@
204208
"reconfigure_addon": {
205209
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::reconfigure_addon::title%]"
206210
},
211+
"show_z2m_docs_url": {
212+
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::description%]",
213+
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::title%]"
214+
},
207215
"start_addon": {
208216
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::start_addon::title%]"
209217
},

homeassistant/components/homeassistant_yellow/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
"reconfigure_addon": {
139139
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::reconfigure_addon::title%]"
140140
},
141+
"show_z2m_docs_url": {
142+
"description": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::description%]",
143+
"title": "[%key:component::homeassistant_hardware::firmware_picker::options::step::show_z2m_docs_url::title%]"
144+
},
141145
"start_addon": {
142146
"title": "[%key:component::homeassistant_hardware::silabs_multiprotocol_hardware::options::step::start_addon::title%]"
143147
},

tests/components/homeassistant_hardware/test_config_flow.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import pytest
1717
from yarl import URL
1818

19+
from homeassistant.components.homeassistant_hardware.const import Z2M_EMBER_DOCS_URL
1920
from homeassistant.components.homeassistant_hardware.firmware_config_flow import (
2021
STEP_PICK_FIRMWARE_THREAD,
2122
STEP_PICK_FIRMWARE_ZIGBEE,
@@ -577,12 +578,26 @@ async def test_config_flow_zigbee_custom_other(hass: HomeAssistant) -> None:
577578
assert pick_result["progress_action"] == "install_firmware"
578579
assert pick_result["step_id"] == "install_zigbee_firmware"
579580

580-
create_result = await consume_progress_flow(
581+
show_z2m_result = await consume_progress_flow(
581582
hass,
582583
flow_id=pick_result["flow_id"],
583584
valid_step_ids=("install_zigbee_firmware",),
584585
)
585586

587+
# After firmware installation, Z2M docs link is shown
588+
assert show_z2m_result["type"] is FlowResultType.FORM
589+
assert show_z2m_result["step_id"] == "show_z2m_docs_url"
590+
assert (
591+
show_z2m_result["description_placeholders"]["z2m_docs_url"]
592+
== Z2M_EMBER_DOCS_URL
593+
)
594+
595+
# Submit the form to complete the flow
596+
create_result = await hass.config_entries.flow.async_configure(
597+
show_z2m_result["flow_id"],
598+
user_input={},
599+
)
600+
586601
assert create_result["type"] is FlowResultType.CREATE_ENTRY
587602

588603
config_entry = create_result["result"]

0 commit comments

Comments
 (0)