@@ -313,7 +313,7 @@ def get_source_key(self, datadict: dict[str, float]) -> str:
313313 # Prefer PM totals on Primary when available.
314314 # Validate PM sensor exists before using it
315315 if self .source_key_pm not in datadict :
316- _LOGGER .warning (f "Parallel Master detected but PM sensor { self . source_key_pm } not found, falling back to { self .source_key } " )
316+ _LOGGER .warning ("Parallel Master detected but PM sensor %s not found, falling back to %s" , self .source_key_pm , self . source_key )
317317 return self .source_key
318318 return self .source_key_pm # Use PM sensor on Master
319319
@@ -327,7 +327,7 @@ def get_value(self, datadict: dict[str, float]) -> float | None:
327327 # This avoids resetting total increasing sensors and unintentionally breaking energy statistics.
328328 value = datadict .get (source_key , None )
329329 if value is None :
330- _LOGGER .debug (f "Source sensor { source_key } not found or has no value, marking unavailable" )
330+ _LOGGER .debug ("Source sensor %s not found or has no value, marking unavailable" , source_key )
331331 return None
332332
333333 # Apply filter function first (universal - applies to all sensor types)
@@ -708,7 +708,7 @@ def _create_sensor_from_mapping(
708708 source_hub: Optional hub to read data from (if different from hub, e.g., for Slave sensors)
709709 name_prefix: Optional prefix to add to sensor name (e.g., "All ", "Solax 1 ")
710710 """
711- _LOGGER .debug (f "_create_sensor_from_mapping: name_prefix='{ name_prefix } ', target_key={ sensor_mapping .target_key } " )
711+ _LOGGER .debug ("_create_sensor_from_mapping: name_prefix='%s ', target_key=%s" , name_prefix , sensor_mapping .target_key )
712712 sensors = []
713713
714714 # Use source_hub if provided, otherwise use hub
@@ -728,7 +728,7 @@ def value_function(initval: Any, descr: Any, datadict: dict[str, Any]) -> Any:
728728 return sensor_mapping .get_value (hub_data )
729729 except Exception as e :
730730 hub_name = getattr (captured_hub , "_name" , "Unknown" )
731- _LOGGER .error (f "Error getting value for { sensor_mapping . target_key } from hub { hub_name } : { e } " )
731+ _LOGGER .error ("Error getting value for %s from hub %s: %s" , sensor_mapping . target_key , hub_name , e )
732732 return None
733733
734734 return value_function
@@ -862,23 +862,23 @@ def value_function(initval: Any, descr: Any, datadict: dict[str, Any]) -> Any:
862862 master_value = sensor_mapping .get_value (master_data )
863863 total = master_value if master_value is not None else 0
864864 except Exception as e :
865- _LOGGER .debug (f" { master_name } : Error getting Master value for aggregation: { e } " )
865+ _LOGGER .debug ("%s : Error getting Master value for aggregation: %s" , master_name , e )
866866 total = 0
867867
868868 # Sum all Slave values
869869 for slave_name , slave_hub in slave_hubs :
870870 try :
871871 slave_data = getattr (slave_hub , "data" , None ) or getattr (slave_hub , "datadict" , {})
872872 if not slave_data :
873- _LOGGER .debug (f" { master_name } : Slave hub '{ slave_name } ' has no data, using 0 for aggregation" )
873+ _LOGGER .debug ("%s : Slave hub '%s ' has no data, using 0 for aggregation", master_name , slave_name )
874874 continue
875875
876876 slave_value = sensor_mapping .get_value (slave_data )
877877 if slave_value is not None :
878878 total += slave_value
879879 # If slave_value is None, treat as 0 (already handled by not adding)
880880 except Exception as e :
881- _LOGGER .debug (f" { master_name } : Error getting Slave '{ slave_name } ' value for aggregation: { e } , using 0" )
881+ _LOGGER .debug ("%s : Error getting Slave '%s ' value for aggregation: %s , using 0", master_name , slave_name , e )
882882 # Continue with other Slaves (treat this Slave as 0)
883883
884884 return total
@@ -929,14 +929,14 @@ async def create_energy_dashboard_sensors(hub: Any, mapping: EnergyDashboardMapp
929929 default = False ,
930930 )
931931 ed_is_master = is_master and not debug_standalone
932- _LOGGER .info (f" { hub_name } : Energy Dashboard sensor creation - parallel_setting={ parallel_setting } , is_master={ is_master } " )
932+ _LOGGER .info ("%s : Energy Dashboard sensor creation - parallel_setting=%s , is_master=%s" , hub_name , parallel_setting , is_master )
933933
934934 # Find Slave hubs if this is a Master
935935 slave_hubs = []
936936 if ed_is_master and hass :
937937 slave_hubs = _find_slave_hubs (hass , hub )
938938 if slave_hubs :
939- _LOGGER .info (f "Found { len ( slave_hubs ) } registered Slave hub(s) for Energy Dashboard" )
939+ _LOGGER .info ("Found %s registered Slave hub(s) for Energy Dashboard" , len ( slave_hubs ) )
940940 else :
941941 _LOGGER .debug ("No Slave hubs found for Energy Dashboard (Master mode but no Slaves)" )
942942 elif ed_is_master and not hass :
@@ -1147,7 +1147,7 @@ def _detect_variants(hub_obj: Any, mapping: Any, base_key: str) -> list[int]:
11471147 # Create "Solax 1" sensor (Master individual)
11481148 # Check if individual sensors should be skipped
11491149 _LOGGER .debug (
1150- f "Master individual check: target_key={ sensor_mapping .target_key } , skip_pm_individuals= { sensor_mapping .skip_pm_individuals } "
1150+ "Master individual check: target_key=%s, skip_pm_individuals=%s" , sensor_mapping .target_key , sensor_mapping .skip_pm_individuals
11511151 )
11521152 if not sensor_mapping .skip_pm_individuals :
11531153 # For Master individual, force use of non-PM sensor by setting source_key_pm=None
@@ -1176,7 +1176,9 @@ def _detect_variants(hub_obj: Any, mapping: Any, base_key: str) -> list[int]:
11761176
11771177 # Create "Solax 2/3" sensors from Slave hubs
11781178 # Check if individual sensors should be skipped
1179- _LOGGER .debug (f"Slave individual check: target_key={ sensor_mapping .target_key } , skip_pm_individuals={ sensor_mapping .skip_pm_individuals } " )
1179+ _LOGGER .debug (
1180+ "Slave individual check: target_key=%s, skip_pm_individuals=%s" , sensor_mapping .target_key , sensor_mapping .skip_pm_individuals
1181+ )
11801182 if not sensor_mapping .skip_pm_individuals :
11811183 for slave_name , slave_hub in slave_hubs :
11821184 sensors .extend (
@@ -1254,12 +1256,12 @@ def validate_mapping(mapping: EnergyDashboardMapping) -> bool:
12541256 bool: True if mapping is valid, False otherwise
12551257 """
12561258 if not mapping .mappings :
1257- _LOGGER .error (f "Plugin { mapping . plugin_name } : No mappings defined" )
1259+ _LOGGER .error ("Plugin %s : No mappings defined" , mapping . plugin_name )
12581260 return False
12591261
12601262 for sensor_mapping in mapping .mappings :
12611263 if not sensor_mapping .source_key or not sensor_mapping .target_key :
1262- _LOGGER .error (f "Invalid mapping: missing source_key or target_key for { mapping .plugin_name } " )
1264+ _LOGGER .error ("Invalid mapping: missing source_key or target_key for %s" , mapping .plugin_name )
12631265 return False
12641266
12651267 return True
0 commit comments