mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix hide empty sections in mqtt subentry flows (#148692)
This commit is contained in:
parent
d4374dbcc7
commit
f7672985ed
@ -2114,6 +2114,9 @@ def data_schema_from_fields(
|
||||
if schema_section is None:
|
||||
data_schema.update(data_schema_element)
|
||||
continue
|
||||
if not data_schema_element:
|
||||
# Do not show empty sections
|
||||
continue
|
||||
collapsed = (
|
||||
not any(
|
||||
(default := data_schema_fields[str(option)].default) is vol.UNDEFINED
|
||||
|
@ -3220,7 +3220,7 @@ async def test_subentry_configflow(
|
||||
"url": learn_more_url(component["platform"]),
|
||||
}
|
||||
|
||||
# Process entity details setep
|
||||
# Process entity details step
|
||||
assert result["step_id"] == "entity_platform_config"
|
||||
|
||||
# First test validators if set of test
|
||||
@ -4212,3 +4212,52 @@ async def test_subentry_reconfigure_availablity(
|
||||
"payload_available": "1",
|
||||
"payload_not_available": "0",
|
||||
}
|
||||
|
||||
|
||||
async def test_subentry_configflow_section_feature(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test the subentry ConfigFlow sections are hidden when they have no configurable options."""
|
||||
await mqtt_mock_entry()
|
||||
config_entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
|
||||
|
||||
result = await hass.config_entries.subentries.async_init(
|
||||
(config_entry.entry_id, "device"),
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "device"
|
||||
result = await hass.config_entries.subentries.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"name": "Bla", "mqtt_settings": {"qos": 1}},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.subentries.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"platform": "fan"},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["description_placeholders"] == {
|
||||
"mqtt_device": "Bla",
|
||||
"platform": "fan",
|
||||
"entity": "Bla",
|
||||
"url": learn_more_url("fan"),
|
||||
}
|
||||
|
||||
# Process entity details step
|
||||
assert result["step_id"] == "entity_platform_config"
|
||||
|
||||
result = await hass.config_entries.subentries.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"fan_feature_speed": True},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "mqtt_platform_config"
|
||||
|
||||
# Check mqtt platform config flow sections from data schema
|
||||
data_schema = result["data_schema"].schema
|
||||
assert "fan_speed_settings" in data_schema
|
||||
assert "fan_preset_mode_settings" not in data_schema
|
||||
|
Loading…
x
Reference in New Issue
Block a user