@@ -111,6 +111,7 @@ class BatteryNotesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
111111 VERSION = CONFIG_VERSION
112112
113113 data : dict
114+ model_info : ModelInfo = None
114115
115116 @staticmethod
116117 @callback
@@ -179,8 +180,11 @@ async def async_step_device(
179180 device_entry .hw_version ,
180181 )
181182
182- model_info = ModelInfo (
183- device_entry .manufacturer , device_entry .model , get_device_model_id (device_entry ), device_entry .hw_version
183+ self .model_info = ModelInfo (
184+ device_entry .manufacturer ,
185+ device_entry .model ,
186+ get_device_model_id (device_entry ),
187+ device_entry .hw_version ,
184188 )
185189
186190 library = await Library .factory (self .hass )
@@ -189,7 +193,7 @@ async def async_step_device(
189193 self .data [CONF_BATTERY_QUANTITY ] = 1
190194
191195 device_battery_details = await library .get_device_battery_details (
192- model_info
196+ self . model_info
193197 )
194198
195199 if device_battery_details and not device_battery_details .is_manual :
@@ -268,7 +272,7 @@ async def async_step_entity(
268272 device_entry .hw_version ,
269273 )
270274
271- model_info = ModelInfo (
275+ self . model_info = ModelInfo (
272276 device_entry .manufacturer ,
273277 device_entry .model ,
274278 get_device_model_id (device_entry ),
@@ -278,7 +282,7 @@ async def async_step_entity(
278282 library = await Library .factory (self .hass )
279283
280284 device_battery_details = await library .get_device_battery_details (
281- model_info
285+ self . model_info
282286 )
283287
284288 if device_battery_details and not device_battery_details .is_manual :
@@ -326,7 +330,6 @@ async def async_step_manual(self, user_input: dict[str, Any] | None = None):
326330 errors = errors ,
327331 )
328332
329-
330333 async def async_step_battery (self , user_input : dict [str , Any ] | None = None ):
331334 """Second step in config flow to add the battery type."""
332335 errors : dict [str , str ] = {}
@@ -375,6 +378,12 @@ async def async_step_battery(self, user_input: dict[str, Any] | None = None):
375378
376379 return self .async_show_form (
377380 step_id = "battery" ,
381+ description_placeholders = {
382+ "manufacturer" : self .model_info .manufacturer if self .model_info else "" ,
383+ "model" : self .model_info .model if self .model_info else "" ,
384+ "model_id" : self .model_info .model_id if self .model_info else "" ,
385+ "hw_version" : self .model_info .hw_version if self .model_info else "" ,
386+ },
378387 data_schema = vol .Schema (
379388 {
380389 vol .Required (
@@ -413,6 +422,8 @@ async def async_step_battery(self, user_input: dict[str, Any] | None = None):
413422class OptionsFlowHandler (OptionsFlow ):
414423 """Handle an option flow for BatteryNotes."""
415424
425+ model_info : ModelInfo = None
426+
416427 def __init__ (self , config_entry : ConfigEntry ) -> None :
417428 """Initialize options flow."""
418429 self .config_entry = config_entry
@@ -433,6 +444,25 @@ async def async_step_init(
433444 errors = {}
434445 self .current_config = dict (self .config_entry .data )
435446
447+ if self .source_device_id :
448+ device_registry = dr .async_get (self .hass )
449+ device_entry = device_registry .async_get (self .source_device_id )
450+
451+ _LOGGER .debug (
452+ "Looking up device %s %s %s %s" ,
453+ device_entry .manufacturer ,
454+ device_entry .model ,
455+ get_device_model_id (device_entry ) or "" ,
456+ device_entry .hw_version ,
457+ )
458+
459+ self .model_info = ModelInfo (
460+ device_entry .manufacturer ,
461+ device_entry .model ,
462+ get_device_model_id (device_entry ),
463+ device_entry .hw_version ,
464+ )
465+
436466 schema = self .build_options_schema ()
437467 if user_input is not None :
438468 user_input [CONF_BATTERY_QUANTITY ] = int (user_input [CONF_BATTERY_QUANTITY ])
@@ -446,6 +476,12 @@ async def async_step_init(
446476
447477 return self .async_show_form (
448478 step_id = "init" ,
479+ description_placeholders = {
480+ "manufacturer" : self .model_info .manufacturer if self .model_info else "" ,
481+ "model" : self .model_info .model if self .model_info else "" ,
482+ "model_id" : self .model_info .model_id if self .model_info else "" ,
483+ "hw_version" : self .model_info .hw_version if self .model_info else "" ,
484+ },
449485 data_schema = schema ,
450486 errors = errors ,
451487 )
0 commit comments