Skip to content

Commit

Permalink
Merge pull request #1 from ebaschiera/master
Browse files Browse the repository at this point in the history
fix for reading temperature less than 10, because current cost adds a sp...
  • Loading branch information
mapkyca committed Dec 13, 2014
2 parents 2ad1177 + b59aee0 commit 7da4a50
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions current-cost.py
Expand Up @@ -103,11 +103,11 @@ def main():

try:
watts_ex = re.compile('<watts>([0-9]+)</watts>')
temp_ex = re.compile('<tmpr>([0-9\.]+)</tmpr>')
temp_ex = re.compile('<tmpr>([\ ]?[0-9\.]+)</tmpr>') # when temperature is less than 10, currentcost adds a space before the number
time_ex = re.compile('<time>([0-9\.\:]+)</time>')

watts = str(int(watts_ex.findall(data)[0])) # cast to and from int to strip leading zeros
temp = temp_ex.findall(data)[0]
temp = temp_ex.findall(data)[0].strip() # remove that extra space
time = time_ex.findall(data)[0]
except:
sys.stderr.write("Could not get details from device")
Expand Down

0 comments on commit 7da4a50

Please sign in to comment.