Skip to content

Commit 187434c

Browse files
committed
Format HOME_MEAS based on UOM
1 parent de64e64 commit 187434c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugwise/smile.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ def get_power_data_from_location(self, loc_id):
842842
peak_list = ["nl_peak", "nl_offpeak"]
843843

844844
# meter_string = ".//{}[type='{}']/"
845-
for measurement in HOME_MEASUREMENTS:
845+
for measurement, attrs in HOME_MEASUREMENTS.items():
846846
for log_type in log_list:
847847
for peak_select in peak_list:
848848
locator = (
@@ -869,7 +869,13 @@ def get_power_data_from_location(self, loc_id):
869869
key_string = f"{measurement}_{peak}_{log_found}"
870870
net_string = f"net_electricity_{log_found}"
871871
val = loc_logs.find(locator).text
872-
f_val = format_measure(val, None)
872+
if all(
873+
item in key_string
874+
for item in ['electricity', 'cumulative']
875+
):
876+
f_val = format_measure(val, ENERGY_KILO_WATT_HOUR)
877+
else:
878+
f_val = format_measure(val, attrs[ATTR_UNIT_OF_MEASUREMENT])
873879
if "gas" in measurement:
874880
key_string = f"{measurement}_{log_found}"
875881
f_val = float(f"{round(float(val), 3):.3f}")

0 commit comments

Comments
 (0)