@@ -229,17 +229,23 @@ async def async_step_account_settings(
229229 for unit_type in self .hub .unit_sensor_unique_ids :
230230 unit = (input if isinstance (input := update_setting .get (unit_type ), Unit )
231231 else Unit (input ) if input else getattr (self .member , unit_type , None ))
232- if not unit . device_class or ( not input and not update_all_units ) :
232+ if ( not unit or not unit . device_class ) and not update_all_units :
233233 continue
234234 _LOGGER .debug ("Updating %s sensor entities" , unit_type )
235- display_precision = ROUNDING_RULES .get (unit , 0 )
236- options = { "unit_of_measurement" : unit .symbol ,
237- "display_precision" : display_precision ,
238- "suggested_display_precision" : display_precision }
239- for unique_id in self .hub .unit_sensor_unique_ids .get (unit_type , {}).get (unit .device_class , []):
240- entity_id = registry .async_get_entity_id (Platform .SENSOR , DOMAIN , unique_id )
241- _LOGGER .debug ("Setting %s to %s with display precision %s" , entity_id , unit .symbol , display_precision )
242- registry .async_update_entity_options (entity_id , Platform .SENSOR , options )
235+ if update_all_units and unit_type == API .FEED_UNIT :
236+ target_units = {"weight" : unit if unit .device_class == "weight" else Unit .GRAMS ,
237+ "volume" : unit if unit .device_class == "volume" else Unit .MILLILITERS }
238+ else :
239+ target_units = {unit .device_class : unit }
240+ for device_class , target_unit in target_units .items ():
241+ display_precision = ROUNDING_RULES .get (target_unit , 0 )
242+ options = { "unit_of_measurement" : target_unit .symbol ,
243+ "display_precision" : display_precision ,
244+ "suggested_display_precision" : display_precision }
245+ for unique_id in self .hub .unit_sensor_unique_ids .get (unit_type , {}).get (device_class , []):
246+ entity_id = registry .async_get_entity_id (Platform .SENSOR , DOMAIN , unique_id )
247+ _LOGGER .debug ("Setting %s to %s with display precision %s" , entity_id , unit .symbol , display_precision )
248+ registry .async_update_entity_options (entity_id , Platform .SENSOR , options )
243249
244250 if not (update_info or update_setting ):
245251 _LOGGER .debug ("No account settings were changed." )
0 commit comments