mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
0.106 Beta - provide correctly formatted placeholders (#32119)
This commit is contained in:
parent
524a1a7587
commit
d2d788631e
@ -270,6 +270,10 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
|
description_placeholders={
|
||||||
|
"host": self.data.get(CONF_HOST, "Unknown"),
|
||||||
|
"port": self.data.get(CONF_PORT, "Unknown"),
|
||||||
|
},
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_HOST, default=self.data.get(CONF_HOST)): str,
|
vol.Required(CONF_HOST, default=self.data.get(CONF_HOST)): str,
|
||||||
@ -556,7 +560,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"zone": "Zone {self.active_cfg}"
|
"zone": f"Zone {self.active_cfg}"
|
||||||
if len(self.active_cfg) < 3
|
if len(self.active_cfg) < 3
|
||||||
else self.active_cfg.upper
|
else self.active_cfg.upper
|
||||||
},
|
},
|
||||||
@ -594,7 +598,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"zone": "Zone {self.active_cfg}"
|
"zone": f"Zone {self.active_cfg}"
|
||||||
if len(self.active_cfg) < 3
|
if len(self.active_cfg) < 3
|
||||||
else self.active_cfg.upper()
|
else self.active_cfg.upper()
|
||||||
},
|
},
|
||||||
@ -624,7 +628,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"zone": "Zone {self.active_cfg}"
|
"zone": f"Zone {self.active_cfg}"
|
||||||
if len(self.active_cfg) < 3
|
if len(self.active_cfg) < 3
|
||||||
else self.active_cfg.upper()
|
else self.active_cfg.upper()
|
||||||
},
|
},
|
||||||
@ -671,7 +675,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"zone": "Zone {self.active_cfg}"
|
"zone": f"Zone {self.active_cfg}"
|
||||||
if len(self.active_cfg) < 3
|
if len(self.active_cfg) < 3
|
||||||
else self.active_cfg.upper()
|
else self.active_cfg.upper()
|
||||||
},
|
},
|
||||||
@ -710,7 +714,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
"zone": "Zone {self.active_cfg}"
|
"zone": f"Zone {self.active_cfg}"
|
||||||
if len(self.active_cfg) < 3
|
if len(self.active_cfg) < 3
|
||||||
else self.active_cfg.upper()
|
else self.active_cfg.upper()
|
||||||
},
|
},
|
||||||
|
@ -597,6 +597,9 @@ async def test_option_flow(hass, mock_panel):
|
|||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "options_binary"
|
assert result["step_id"] == "options_binary"
|
||||||
|
assert result["description_placeholders"] == {
|
||||||
|
"zone": "Zone 2",
|
||||||
|
}
|
||||||
|
|
||||||
# zone 2
|
# zone 2
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
@ -604,6 +607,9 @@ async def test_option_flow(hass, mock_panel):
|
|||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "options_binary"
|
assert result["step_id"] == "options_binary"
|
||||||
|
assert result["description_placeholders"] == {
|
||||||
|
"zone": "Zone 6",
|
||||||
|
}
|
||||||
|
|
||||||
# zone 6
|
# zone 6
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
@ -612,6 +618,9 @@ async def test_option_flow(hass, mock_panel):
|
|||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "options_digital"
|
assert result["step_id"] == "options_digital"
|
||||||
|
assert result["description_placeholders"] == {
|
||||||
|
"zone": "Zone 3",
|
||||||
|
}
|
||||||
|
|
||||||
# zone 3
|
# zone 3
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
@ -619,6 +628,9 @@ async def test_option_flow(hass, mock_panel):
|
|||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "options_switch"
|
assert result["step_id"] == "options_switch"
|
||||||
|
assert result["description_placeholders"] == {
|
||||||
|
"zone": "Zone 4",
|
||||||
|
}
|
||||||
|
|
||||||
# zone 4
|
# zone 4
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
@ -626,6 +638,9 @@ async def test_option_flow(hass, mock_panel):
|
|||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == "options_switch"
|
assert result["step_id"] == "options_switch"
|
||||||
|
assert result["description_placeholders"] == {
|
||||||
|
"zone": "OUT",
|
||||||
|
}
|
||||||
|
|
||||||
# zone out
|
# zone out
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -250,6 +250,74 @@ async def test_setup_defined_hosts_no_known_auth(hass):
|
|||||||
assert len(hass.config_entries.flow.async_progress()) == 1
|
assert len(hass.config_entries.flow.async_progress()) == 1
|
||||||
|
|
||||||
|
|
||||||
|
async def test_setup_multiple(hass):
|
||||||
|
"""Test we initiate config entry for multiple panels."""
|
||||||
|
assert (
|
||||||
|
await async_setup_component(
|
||||||
|
hass,
|
||||||
|
konnected.DOMAIN,
|
||||||
|
{
|
||||||
|
konnected.DOMAIN: {
|
||||||
|
konnected.CONF_ACCESS_TOKEN: "arandomstringvalue",
|
||||||
|
konnected.CONF_API_HOST: "http://192.168.86.32:8123",
|
||||||
|
konnected.CONF_DEVICES: [
|
||||||
|
{
|
||||||
|
konnected.CONF_ID: "aabbccddeeff",
|
||||||
|
"binary_sensors": [
|
||||||
|
{
|
||||||
|
"zone": 4,
|
||||||
|
"type": "motion",
|
||||||
|
"name": "Hallway Motion",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"zone": 5,
|
||||||
|
"type": "window",
|
||||||
|
"name": "Master Bedroom Window",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"zone": 6,
|
||||||
|
"type": "window",
|
||||||
|
"name": "Downstairs Windows",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"switches": [{"zone": "out", "name": "siren"}],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
konnected.CONF_ID: "445566778899",
|
||||||
|
"binary_sensors": [
|
||||||
|
{"zone": 1, "type": "motion", "name": "Front"},
|
||||||
|
{"zone": 2, "type": "window", "name": "Back"},
|
||||||
|
],
|
||||||
|
"switches": [
|
||||||
|
{
|
||||||
|
"zone": "out",
|
||||||
|
"name": "Buzzer",
|
||||||
|
"momentary": 65,
|
||||||
|
"pause": 55,
|
||||||
|
"repeat": 4,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
is True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Flow started for discovered bridge
|
||||||
|
assert len(hass.config_entries.flow.async_progress()) == 2
|
||||||
|
|
||||||
|
# Globals saved
|
||||||
|
assert (
|
||||||
|
hass.data[konnected.DOMAIN][konnected.CONF_ACCESS_TOKEN] == "arandomstringvalue"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
hass.data[konnected.DOMAIN][konnected.CONF_API_HOST]
|
||||||
|
== "http://192.168.86.32:8123"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_config_passed_to_config_entry(hass):
|
async def test_config_passed_to_config_entry(hass):
|
||||||
"""Test that configured options for a host are loaded via config entry."""
|
"""Test that configured options for a host are loaded via config entry."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user