mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Tweak title of zha config entry created by yellow hw (#73797)
This commit is contained in:
parent
67618311fa
commit
274f585646
@ -23,12 +23,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"zha",
|
"zha",
|
||||||
context={"source": "hardware"},
|
context={"source": "hardware"},
|
||||||
data={
|
data={
|
||||||
"radio_type": "efr32",
|
"name": "Yellow",
|
||||||
"port": {
|
"port": {
|
||||||
"path": "/dev/ttyAMA1",
|
"path": "/dev/ttyAMA1",
|
||||||
"baudrate": 115200,
|
"baudrate": 115200,
|
||||||
"flow_control": "hardware",
|
"flow_control": "hardware",
|
||||||
},
|
},
|
||||||
|
"radio_type": "efr32",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ class ZhaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
except vol.Invalid:
|
except vol.Invalid:
|
||||||
return self.async_abort(reason="invalid_hardware_data")
|
return self.async_abort(reason="invalid_hardware_data")
|
||||||
|
|
||||||
self._title = data["port"]["path"]
|
self._title = data.get("name", data["port"]["path"])
|
||||||
|
|
||||||
self._set_confirm_only()
|
self._set_confirm_only()
|
||||||
return await self.async_step_confirm_hardware()
|
return await self.async_step_confirm_hardware()
|
||||||
|
@ -41,6 +41,41 @@ async def test_setup_entry(
|
|||||||
assert len(hass.config_entries.flow.async_progress_by_handler("zha")) == num_flows
|
assert len(hass.config_entries.flow.async_progress_by_handler("zha")) == num_flows
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_zha(hass: HomeAssistant) -> None:
|
||||||
|
"""Test zha gets the right config."""
|
||||||
|
mock_integration(hass, MockModule("hassio"))
|
||||||
|
|
||||||
|
# Setup the config entry
|
||||||
|
config_entry = MockConfigEntry(
|
||||||
|
data={},
|
||||||
|
domain=DOMAIN,
|
||||||
|
options={},
|
||||||
|
title="Home Assistant Yellow",
|
||||||
|
)
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.homeassistant_yellow.get_os_info",
|
||||||
|
return_value={"board": "yellow"},
|
||||||
|
) as mock_get_os_info, patch(
|
||||||
|
"homeassistant.components.onboarding.async_is_onboarded", return_value=False
|
||||||
|
):
|
||||||
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert len(mock_get_os_info.mock_calls) == 1
|
||||||
|
|
||||||
|
config_entry = hass.config_entries.async_entries("zha")[0]
|
||||||
|
assert config_entry.data == {
|
||||||
|
"device": {
|
||||||
|
"baudrate": 115200,
|
||||||
|
"flow_control": "hardware",
|
||||||
|
"path": "/dev/ttyAMA1",
|
||||||
|
},
|
||||||
|
"radio_type": "ezsp",
|
||||||
|
}
|
||||||
|
assert config_entry.options == {}
|
||||||
|
assert config_entry.title == "Yellow"
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_entry_wrong_board(hass: HomeAssistant) -> None:
|
async def test_setup_entry_wrong_board(hass: HomeAssistant) -> None:
|
||||||
"""Test setup of a config entry with wrong board type."""
|
"""Test setup of a config entry with wrong board type."""
|
||||||
mock_integration(hass, MockModule("hassio"))
|
mock_integration(hass, MockModule("hassio"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user