Add audio support option to HomeKit camera UI config flow (#56107)
This commit is contained in:
parent
eff59e8b00
commit
371aa03bca
4 changed files with 155 additions and 4 deletions
|
@ -753,7 +753,10 @@ async def test_options_flow_include_mode_with_cameras(hass, mock_get_source_ip):
|
|||
)
|
||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result2["step_id"] == "cameras"
|
||||
assert result2["data_schema"]({}) == {"camera_copy": ["camera.native_h264"]}
|
||||
assert result2["data_schema"]({}) == {
|
||||
"camera_copy": ["camera.native_h264"],
|
||||
"camera_audio": [],
|
||||
}
|
||||
schema = result2["data_schema"].schema
|
||||
assert _get_schema_default(schema, "camera_copy") == ["camera.native_h264"]
|
||||
|
||||
|
@ -776,6 +779,136 @@ async def test_options_flow_include_mode_with_cameras(hass, mock_get_source_ip):
|
|||
}
|
||||
|
||||
|
||||
async def test_options_flow_with_camera_audio(hass, mock_get_source_ip):
|
||||
"""Test config flow options with cameras that support audio."""
|
||||
|
||||
config_entry = _mock_config_entry_with_options_populated()
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
hass.states.async_set("climate.old", "off")
|
||||
hass.states.async_set("camera.audio", "off")
|
||||
hass.states.async_set("camera.no_audio", "off")
|
||||
hass.states.async_set("camera.excluded", "off")
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(
|
||||
config_entry.entry_id, context={"show_advanced_options": False}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"domains": ["fan", "vacuum", "climate", "camera"]},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "include_exclude"
|
||||
|
||||
result2 = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
"entities": ["camera.audio", "camera.no_audio"],
|
||||
"include_exclude_mode": "include",
|
||||
},
|
||||
)
|
||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result2["step_id"] == "cameras"
|
||||
|
||||
result3 = await hass.config_entries.options.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={"camera_audio": ["camera.audio"]},
|
||||
)
|
||||
|
||||
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert config_entry.options == {
|
||||
"auto_start": True,
|
||||
"mode": "bridge",
|
||||
"filter": {
|
||||
"exclude_domains": [],
|
||||
"exclude_entities": [],
|
||||
"include_domains": ["fan", "vacuum", "climate"],
|
||||
"include_entities": ["camera.audio", "camera.no_audio"],
|
||||
},
|
||||
"entity_config": {"camera.audio": {"support_audio": True}},
|
||||
}
|
||||
|
||||
# Now run though again and verify we can turn off audio
|
||||
|
||||
result = await hass.config_entries.options.async_init(
|
||||
config_entry.entry_id, context={"show_advanced_options": False}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "init"
|
||||
assert result["data_schema"]({}) == {
|
||||
"domains": ["fan", "vacuum", "climate", "camera"],
|
||||
"mode": "bridge",
|
||||
}
|
||||
schema = result["data_schema"].schema
|
||||
assert _get_schema_default(schema, "domains") == [
|
||||
"fan",
|
||||
"vacuum",
|
||||
"climate",
|
||||
"camera",
|
||||
]
|
||||
assert _get_schema_default(schema, "mode") == "bridge"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"domains": ["fan", "vacuum", "climate", "camera"]},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "include_exclude"
|
||||
assert result["data_schema"]({}) == {
|
||||
"entities": ["camera.audio", "camera.no_audio"],
|
||||
"include_exclude_mode": "include",
|
||||
}
|
||||
schema = result["data_schema"].schema
|
||||
assert _get_schema_default(schema, "entities") == [
|
||||
"camera.audio",
|
||||
"camera.no_audio",
|
||||
]
|
||||
assert _get_schema_default(schema, "include_exclude_mode") == "include"
|
||||
|
||||
result2 = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
"entities": ["climate.old", "camera.excluded"],
|
||||
"include_exclude_mode": "exclude",
|
||||
},
|
||||
)
|
||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result2["step_id"] == "cameras"
|
||||
assert result2["data_schema"]({}) == {
|
||||
"camera_copy": [],
|
||||
"camera_audio": ["camera.audio"],
|
||||
}
|
||||
schema = result2["data_schema"].schema
|
||||
assert _get_schema_default(schema, "camera_audio") == ["camera.audio"]
|
||||
|
||||
result3 = await hass.config_entries.options.async_configure(
|
||||
result2["flow_id"],
|
||||
user_input={"camera_audio": []},
|
||||
)
|
||||
|
||||
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert config_entry.options == {
|
||||
"auto_start": True,
|
||||
"entity_config": {"camera.audio": {}},
|
||||
"filter": {
|
||||
"exclude_domains": [],
|
||||
"exclude_entities": ["climate.old", "camera.excluded"],
|
||||
"include_domains": ["fan", "vacuum", "climate", "camera"],
|
||||
"include_entities": [],
|
||||
},
|
||||
"mode": "bridge",
|
||||
}
|
||||
|
||||
|
||||
async def test_options_flow_blocked_when_from_yaml(hass, mock_get_source_ip):
|
||||
"""Test config flow options."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue