File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -160,15 +160,13 @@ def power_data_local_format(
160160 attrs : dict [str , str ], key_string : str , val : str
161161) -> float | int | bool :
162162 """Format power data."""
163- attrs_uom = getattr (attrs , ATTR_UNIT_OF_MEASUREMENT )
164- f_val = format_measure (val , attrs_uom )
165- # Format only P1_MEASUREMENT POWER_WATT values, do not move to util-format_meaure function!
166- if attrs_uom == POWER_WATT :
167- f_val = int (round (float (val )))
163+ # Special formatting of P1_MEASUREMENT POWER_WATT values, do not move to util-format_measure() function!
164+ if (attrs_uom := getattr (attrs , ATTR_UNIT_OF_MEASUREMENT )) == POWER_WATT :
165+ return int (round (float (val )))
168166 if all (item in key_string for item in ("electricity" , "cumulative" )):
169- f_val = format_measure (val , ENERGY_KILO_WATT_HOUR )
167+ return format_measure (val , ENERGY_KILO_WATT_HOUR )
170168
171- return f_val
169+ return format_measure ( val , attrs_uom )
172170
173171
174172def power_data_energy_diff (
You can’t perform that action at this time.
0 commit comments