Skip to content

Commit a0629ef

Browse files
authored
remove advanced options (#722)
OpenHomeFoundation/roadmap#54
1 parent 9142001 commit a0629ef

2 files changed

Lines changed: 26 additions & 34 deletions

File tree

custom_components/bms_ble/config_flow.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
TextSelectorConfig,
3737
TextSelectorType,
3838
)
39-
from homeassistant.helpers.typing import VolDictType
4039

4140
from .const import CONF_ADVANCED_OPTIONS, CONF_KEEP_ALIVE, DOMAIN, LOGGER
4241

@@ -213,34 +212,30 @@ async def async_step_init(
213212
)
214213
if not bms_class:
215214
return self.async_abort(reason="not_supported")
216-
if not bms_class.accept_secret and not self.show_advanced_options:
217-
LOGGER.debug("No options for %s", bms_class.bms_id())
218-
return self.async_abort(
219-
reason="device_has_no_options",
220-
description_placeholders={"model": bms_class.bms_id()},
221-
)
222-
223-
schema_dict: VolDictType = {
224-
vol.Optional(CONF_PASSWORD): TextSelector(
225-
TextSelectorConfig(
226-
type=TextSelectorType.PASSWORD,
227-
read_only=not bms_class.accept_secret,
228-
)
229-
)
230-
}
231-
232-
if self.show_advanced_options:
233-
schema_dict[vol.Optional(CONF_ADVANCED_OPTIONS)] = section(
234-
vol.Schema(
235-
{vol.Optional(CONF_KEEP_ALIVE, default=True): BooleanSelector()}
236-
),
237-
{"collapsed": True},
238-
)
239215

240216
return self.async_show_form(
241217
step_id="init",
242218
data_schema=self.add_suggested_values_to_schema(
243-
vol.Schema(schema_dict),
219+
vol.Schema(
220+
{
221+
vol.Optional(CONF_PASSWORD): TextSelector(
222+
TextSelectorConfig(
223+
type=TextSelectorType.PASSWORD,
224+
read_only=not bms_class.accept_secret,
225+
)
226+
),
227+
vol.Optional(CONF_ADVANCED_OPTIONS): section(
228+
vol.Schema(
229+
{
230+
vol.Optional(
231+
CONF_KEEP_ALIVE, default=True
232+
): BooleanSelector()
233+
}
234+
),
235+
{"collapsed": True},
236+
),
237+
}
238+
),
244239
self.config_entry.options,
245240
),
246241
)

tests/test_config_flow.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ async def test_async_setup_entry(
303303

304304

305305
@pytest.mark.usefixtures("enable_bluetooth")
306-
async def test_setup_entry_missing_unique_id(bms_fixture: str, hass: HomeAssistant) -> None:
306+
async def test_setup_entry_missing_unique_id(
307+
bms_fixture: str, hass: HomeAssistant
308+
) -> None:
307309
"""Test async_setup_entry with missing unique id."""
308310

309311
cfg: MockConfigEntry = mock_config(bms=bms_fixture, unique_id=None)
@@ -452,20 +454,15 @@ async def test_options_flow(
452454

453455

454456
@pytest.mark.usefixtures("enable_bluetooth")
455-
@pytest.mark.parametrize("show_adv_opt", [True, False], ids=["adv_opt", "no_adv_opt"])
456-
async def test_options_flow_no_secret(hass: HomeAssistant, show_adv_opt: bool) -> None:
457-
"""Test if options flow for BMS without secret and disabled advanced mode."""
457+
async def test_options_flow_no_secret(hass: HomeAssistant) -> None:
458+
"""Test if options flow for BMS without secret."""
458459

459460
cfg: MockConfigEntry = mock_config()
460461
cfg.add_to_hass(hass)
461462

462463
result: ConfigFlowResult = await hass.config_entries.options.async_init(
463-
cfg.entry_id, context={"show_advanced_options": show_adv_opt}
464+
cfg.entry_id
464465
)
465-
if not show_adv_opt: # Abort without advanced mode
466-
assert result.get("type") is FlowResultType.ABORT
467-
assert result.get("reason") == "device_has_no_options"
468-
return
469466

470467
assert result.get("type") is FlowResultType.FORM
471468
assert result.get("step_id") == "init"

0 commit comments

Comments
 (0)