We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3e15d3 commit 65bc8abCopy full SHA for 65bc8ab
plugwise/util.py
@@ -10,7 +10,13 @@
10
11
import crcmod
12
13
-from .constants import LOGADDR_OFFSET, PLUGWISE_EPOCH, UTF8_DECODE
+from .constants import (
14
+ ENERGY_KILO_WATT_HOUR,
15
+ LOGADDR_OFFSET,
16
+ PERCENTAGE,
17
+ PLUGWISE_EPOCH,
18
+ UTF8_DECODE,
19
+)
20
21
crc_fun = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000)
22
@@ -67,6 +73,10 @@ def escape_illegal_xml_characters(xmldata):
67
73
68
74
def format_measure(measure, unit):
69
75
"""Format measure to correct type."""
76
+ if unit == PERCENTAGE:
77
+ measure = int(measure * 100)
78
+ if unit == ENERGY_KILO_WATT_HOUR:
79
+ measure = measure / 1000
70
80
try:
71
81
measure = int(measure)
72
82
except ValueError:
0 commit comments