2023-02-21 16:34:40 +01:00
|
|
|
from datetime import timedelta
|
|
|
|
|
2023-02-21 14:00:07 +01:00
|
|
|
def consumption_diff(before, after):
|
|
|
|
out = {}
|
|
|
|
for key in after:
|
2023-02-21 16:34:40 +01:00
|
|
|
out[key] = after.get(key, 0) - before.get(key, 0)
|
2023-02-21 14:00:07 +01:00
|
|
|
return out
|
|
|
|
|
|
|
|
def consumption_to_string(dic):
|
|
|
|
out = ''
|
|
|
|
for key in dic:
|
|
|
|
out += '{0:s}:\t{1:.2f}W\n'.format(key, dic[key])
|
|
|
|
out += 'Total:\t{0:.2f}W'.format(sum(dic.values()))
|
|
|
|
return out
|
2023-02-21 16:34:40 +01:00
|
|
|
|
|
|
|
def stohms(s):
|
|
|
|
return str(timedelta(seconds = s))
|