@@ -107,7 +107,15 @@ class SchemaFlowMenuStep(SchemaFlowStep):
107107 """Define a config or options flow menu step."""
108108
109109 # Menu options
110- options : Container [str ]
110+ options : (
111+ Container [str ]
112+ | Callable [[SchemaCommonFlowHandler ], Coroutine [Any , Any , Container [str ]]]
113+ )
114+ """Menu options, or function which returns menu options.
115+
116+ - If a function is specified, the function will be passed the current
117+ `SchemaCommonFlowHandler`.
118+ """
111119
112120
113121class SchemaCommonFlowHandler :
@@ -152,6 +160,11 @@ async def async_step(
152160 return await self ._async_form_step (step_id , user_input )
153161 return await self ._async_menu_step (step_id , user_input )
154162
163+ async def _get_options (self , form_step : SchemaFlowMenuStep ) -> Container [str ]:
164+ if isinstance (form_step .options , Container ):
165+ return form_step .options
166+ return await form_step .options (self )
167+
155168 async def _get_schema (self , form_step : SchemaFlowFormStep ) -> vol .Schema | None :
156169 if form_step .schema is None :
157170 return None
@@ -255,7 +268,7 @@ async def _show_next_step(
255268 menu_step = cast (SchemaFlowMenuStep , self ._flow [next_step_id ])
256269 return self ._handler .async_show_menu (
257270 step_id = next_step_id ,
258- menu_options = menu_step . options ,
271+ menu_options = await self . _get_options ( menu_step ) ,
259272 )
260273
261274 form_step = cast (SchemaFlowFormStep , self ._flow [next_step_id ])
@@ -308,7 +321,7 @@ async def _async_menu_step(
308321 menu_step : SchemaFlowMenuStep = cast (SchemaFlowMenuStep , self ._flow [step_id ])
309322 return self ._handler .async_show_menu (
310323 step_id = step_id ,
311- menu_options = menu_step . options ,
324+ menu_options = await self . _get_options ( menu_step ) ,
312325 )
313326
314327
0 commit comments