|
|
@@ -12,6 +12,7 @@
|
|
|
import pyemvue
|
|
|
import json
|
|
|
import time
|
|
|
+import sys
|
|
|
|
|
|
from pyemvue.enums import Scale, Unit
|
|
|
from pyemvue import PyEmVue
|
|
|
@@ -23,6 +24,9 @@ DAYS_BACK = 14 # Number of days in the past to get per-minute data for.
|
|
|
MAX_HOURS = 12 # The maxinum number of hours that can be retrieved at once.
|
|
|
MAX_ATTEMPTS = 5
|
|
|
|
|
|
+def eprint(*args, **kwargs):
|
|
|
+ print(*args, file=sys.stderr, **kwargs)
|
|
|
+
|
|
|
# Get & display minutely data for all devices.
|
|
|
def allUsageOverTime(vue: PyEmVue):
|
|
|
devices = vue.get_devices()
|
|
|
@@ -74,13 +78,13 @@ def getChartUsage(vue: PyEmVue, channel, start_time, end_time):
|
|
|
)
|
|
|
except Exception as e:
|
|
|
if attempt < MAX_ATTEMPTS:
|
|
|
- print(
|
|
|
+ eprint(
|
|
|
f'Attempt {attempt} for channel {channel.name}',
|
|
|
f'from {start_time} to {end_time}',
|
|
|
f'failed:', e)
|
|
|
time.sleep(5)
|
|
|
else:
|
|
|
- print(f'Failed after {attempt} attempts')
|
|
|
+ eprint(f'Failed after {attempt} attempts')
|
|
|
raise
|
|
|
|
|
|
if __name__ == '__main__':
|