Fix MotionEye config flow (#64360)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
d3374ecd8e
commit
65ea54927d
2 changed files with 27 additions and 11 deletions
|
@ -222,17 +222,15 @@ class MotionEyeOptionsFlow(OptionsFlow):
|
|||
|
||||
if self.show_advanced_options:
|
||||
# The input URL is not validated as being a URL, to allow for the possibility
|
||||
# the template input won't be a valid URL until after it's rendered.
|
||||
schema.update(
|
||||
{
|
||||
vol.Required(
|
||||
CONF_STREAM_URL_TEMPLATE,
|
||||
default=self._config_entry.options.get(
|
||||
CONF_STREAM_URL_TEMPLATE,
|
||||
"",
|
||||
),
|
||||
): str
|
||||
# the template input won't be a valid URL until after it's rendered
|
||||
stream_kwargs = {}
|
||||
if CONF_STREAM_URL_TEMPLATE in self._config_entry.options:
|
||||
stream_kwargs["description"] = {
|
||||
"suggested_value": self._config_entry.options[
|
||||
CONF_STREAM_URL_TEMPLATE
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
schema[vol.Optional(CONF_STREAM_URL_TEMPLATE, **stream_kwargs)] = str
|
||||
|
||||
return self.async_show_form(step_id="init", data_schema=vol.Schema(schema))
|
||||
|
|
|
@ -480,6 +480,24 @@ async def test_advanced_options(hass: HomeAssistant) -> None:
|
|||
) as mock_setup_entry:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(
|
||||
config_entry.entry_id, context={"show_advanced_options": True}
|
||||
)
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_WEBHOOK_SET: True,
|
||||
CONF_WEBHOOK_SET_OVERWRITE: True,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["data"][CONF_WEBHOOK_SET]
|
||||
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
||||
assert CONF_STREAM_URL_TEMPLATE not in result["data"]
|
||||
assert len(mock_setup.mock_calls) == 0
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
result = await hass.config_entries.options.async_init(
|
||||
config_entry.entry_id, context={"show_advanced_options": True}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue