|
|
@@ -3,6 +3,9 @@ import RainEagle |
|
|
|
import sys |
|
|
|
import time |
|
|
|
|
|
|
|
def print_data(*args): |
|
|
|
print '\t'.join(x.encode('utf8').encode('string-escape') for x in args) |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
with open('eagle.config') as fp: |
|
|
|
conf = json.load(fp) |
|
|
@@ -26,8 +29,10 @@ if __name__ == '__main__': |
|
|
|
#print `raineagle.get_instantaneous_demand(macid)` |
|
|
|
#print `raineagle.get_summation_values(macid, interval='day')` |
|
|
|
#print `raineagle.get_fast_poll_status(macid)` |
|
|
|
|
|
|
|
interval = conf.get('interval', 10) |
|
|
|
s = time.time() |
|
|
|
tzinterval = conf.get('tzinterval', 24*60*60) |
|
|
|
tzs = s = time.time() |
|
|
|
while True: |
|
|
|
usage_data = raineagle.get_usage_data(macid) |
|
|
|
if False: |
|
|
@@ -37,8 +42,19 @@ if __name__ == '__main__': |
|
|
|
fields = [ 'demand_timestamp', 'meter_status', 'demand', |
|
|
|
'threshold_upper_demand', 'demand_units', 'summation_delivered', |
|
|
|
'summation_received', 'summation_units', ] |
|
|
|
print '\t'.join(usage_data[x].encode('utf8').encode('string-escape') for x in fields) |
|
|
|
print_data('l', *(usage_data[x] for x in fields)) |
|
|
|
e = time.time() |
|
|
|
|
|
|
|
if e >= tzs: |
|
|
|
tzs += tzinterval |
|
|
|
# {u'timezone_tzName': u'GMT+7', u'timezone_status': u'success', u'timezone_localTime': u'1571844539', u'timezone_olsonName': u'Etc/GMT+7', u'timezone_utcTime': u'1571869739', u'timezone_utcOffset': u'-0700'} |
|
|
|
tzinfo = raineagle.get_timezone(macid) |
|
|
|
tzoffset = int(tzinfo['timezone_utcTime']) - \ |
|
|
|
int(tzinfo['timezone_localTime']) |
|
|
|
tzfields = [ 'timezone_tzName', 'timezone_localTime', |
|
|
|
'timezone_utcTime', 'timezone_utcOffset' ] |
|
|
|
print_data('z', *(tzinfo[x] for x in tzfields)) |
|
|
|
|
|
|
|
s += interval |
|
|
|
delay = s - e |
|
|
|
print `delay` |