Skip to content

Commit a336e85

Browse files
committed
Implement comments, add note
1 parent 485aa47 commit a336e85

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

plugwise/smile.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,10 @@ def get_power_data_from_location(self, loc_id):
900900
key_string = f"{measurement}_{peak}_{log_found}"
901901
net_string = f"net_electricity_{log_found}"
902902
val = loc_logs.find(locator).text
903+
f_val = format_measure(val, attrs[ATTR_UNIT_OF_MEASUREMENT])
904+
# Format only HOME_MEASUREMENT POWER_WATT values, do not move to util-format_meaure function!
903905
if attrs[ATTR_UNIT_OF_MEASUREMENT] == POWER_WATT:
904906
f_val = int(round(float(val)))
905-
else:
906-
f_val = format_measure(val, attrs[ATTR_UNIT_OF_MEASUREMENT])
907907
if all(
908908
item in key_string for item in ["electricity", "cumulative"]
909909
):
@@ -915,13 +915,10 @@ def get_power_data_from_location(self, loc_id):
915915
diff = -1
916916
if net_string not in direct_data:
917917
direct_data[net_string] = 0
918-
if f_val != 0:
919-
if isinstance(f_val, int):
920-
direct_data[net_string] += int(
921-
round(float(f_val * diff))
922-
)
923-
else:
924-
direct_data[net_string] += float(f_val * diff)
918+
if isinstance(f_val, int):
919+
direct_data[net_string] += f_val * diff
920+
else:
921+
direct_data[net_string] += float(f_val * diff)
925922

926923
if "gas" in measurement:
927924
key_string = f"{measurement}_{log_found}"

0 commit comments

Comments
 (0)