Prompt file imported from ruaan-deysel/ha-unraid (
.github/prompts/Add Config Option.prompt.md). Copyright stays with the author.
Add Config Option
Add a new option to the Unraid integration's options flow.
Context
Read these files before starting:
AGENTS.md— Full project documentationcustom_components/unraid/config_flow.py—UnraidOptionsFlowHandlerclasscustom_components/unraid/const.py— Configuration key constantscustom_components/unraid/strings.json— Translation keys for options UI
Steps
-
Add constant to
const.py:CONF_MY_OPTION: Final = "my_option" DEFAULT_MY_OPTION: Final = some_default -
Update options flow in
config_flow.py:- Add field to
vol.SchemainUnraidOptionsFlowHandler.async_step_init() - Add default value handling from
self.config_entry.options.get()
- Add field to
-
Add translations to
strings.json:"options": { "step": { "init": { "data": { "my_option": "My Option Label" }, "data_description": { "my_option": "Description shown below the field" } } } } -
Use the option where needed:
my_option = entry.options.get(CONF_MY_OPTION, DEFAULT_MY_OPTION) -
Test the option in
tests/test_config_flow.py
Rules
- Options flow uses
OptionsFlowWithReload— entry reloads automatically on save - Use appropriate
volvalidators and selectors for the UI - Provide
data_descriptionfor user guidance - Test both default values and user-provided values