diff --git a/RainEagle/EagleClass.py b/RainEagle/EagleClass.py
index 0a35fdc..dc9da82 100644
--- a/RainEagle/EagleClass.py
+++ b/RainEagle/EagleClass.py
@@ -167,8 +167,8 @@ class Eagle(object) :
print "debug : = ", self.debug
- if self.addr is None :
- raise AssertionError("no hostname or IP given")
+ if self.addr is None :
+ raise AssertionError("no hostname or IP given")
# preload
if self.mac is None :
@@ -183,13 +183,13 @@ class Eagle(object) :
print "Init DeviceMacId = ", self.macid
if self.checkfw :
- mysetting = self.get_setting_data()
- dev_fw_ver = mysetting['device_fw_version']
- if ( LooseVersion(dev_fw_ver) < LooseVersion(min_fw_ver) ) :
- warn_message = "Warning : device firmware " \
- + "{0} < {1} please concideer " \
- + "updating ".format(dev_fw_ver, min_fw_ver)
- warn( warn_message, RuntimeWarning, stacklevel=3)
+ mysetting = self.get_setting_data()
+ dev_fw_ver = mysetting['device_fw_version']
+ if ( LooseVersion(dev_fw_ver) < LooseVersion(min_fw_ver) ) :
+ warn_message = "Warning : device firmware " \
+ + "{0} < {1} please concideer " \
+ + "updating ".format(dev_fw_ver, min_fw_ver)
+ warn( warn_message, RuntimeWarning, stacklevel=3)
@@ -197,8 +197,8 @@ class Eagle(object) :
def list_devices(self, macid=None):
"""
- Send the LIST_DEVICES command
- returns information about the EAGLE device
+ Send the LIST_DEVICES command
+ returns information about the EAGLE device
"""
comm_responce = self._send_soc_comm("list_devices", MacId=macid)
@@ -221,7 +221,7 @@ class Eagle(object) :
if comm_responce is None:
raise RainEagleResponseError("get_device_data : Null reply")
if self.debug :
- print comm_responce
+ print comm_responce
etree = ET.fromstring('' + comm_responce + '')
rv = _et2d(etree)
return rv
@@ -331,6 +331,7 @@ class Eagle(object) :
return rv
# 17
+ # needs to be rewritten to stream the data via iter
def get_history_data(self, macid=None, starttime="0x00000000", endtime=None, frequency=None) :
""" Send the GET_HISTORY_DATA command
get a series of summation values over an interval of time
@@ -361,8 +362,8 @@ class Eagle(object) :
def get_device_list(self, macid=None) :
"""
- Send the LIST_DEVICES command
- returns information about the EAGLE device
+ Send the LIST_DEVICES command
+ returns information about the EAGLE device
"""
comm_responce = self._send_http_comm("get_device_list", MacId=macid)
@@ -419,7 +420,7 @@ class Eagle(object) :
"""
id = _tohex(id)
comm_responce = self._send_http_comm("confirm_message",
- MacId=macid, Id=id)
+ MacId=macid, Id=id)
return json.loads(comm_responce)
def get_message(self, macid=None) :
@@ -595,7 +596,7 @@ class Eagle(object) :
if status not in ['on', 'off'] :
raise ValueError("set_remote_management status must be 'on' or 'off'")
comm_responce = self._send_http_comm("set_remote_management",
- MacId=macid, Status=status)
+ MacId=macid, Status=status)
return json.loads(comm_responce)
@@ -615,7 +616,7 @@ class Eagle(object) :
if source not in ['meter', 'internet'] :
raise ValueError("set_time_source Source must be 'meter' or 'internet'")
comm_responce = self._send_http_comm("set_time_source",
- MacId=macid, Source=source)
+ MacId=macid, Source=source)
return json.loads(comm_responce)
def get_price(self, macid=None) :
@@ -674,7 +675,7 @@ class Eagle(object) :
'set_price_status': 'success'
"""
comm_responce = self._send_http_comm("set_price",
- MacId=macid,
+ MacId=macid,
Price="0xFFFFFFFF",
TrailingDigits="0x00")
return json.loads(comm_responce)
@@ -724,7 +725,7 @@ class Eagle(object) :
See also get_uploader() to retrieve current uploader cloud config
"""
- if url is None :
+ if url is None :
raise ValueError("invalid url.\n")
if url.__len__() > 200 :
@@ -781,8 +782,8 @@ class Eagle(object) :
def _send_http_comm(self, cmd, **kwargs):
- if self.debug :
- print "\n\n_send_http_comm : ", cmd
+ if self.debug :
+ print "\n\n_send_http_comm : ", cmd
commstr = "\n"
commstr += "{0!s}\n".format(cmd)
@@ -791,8 +792,12 @@ class Eagle(object) :
commstr += "<{0}>{1!s}{0}>\n".format(k, v)
commstr += "\n"
- if self.debug :
- print(commstr)
+ if cmd == "set_cloud" :
+ print(commstr)
+ return dict()
+
+ if self.debug :
+ print(commstr)
url = "http://{0}/cgi-bin/cgi_manager".format(self.addr)
diff --git a/bin/meter_status.py b/bin/meter_status.py
index 42b78f3..496b9e9 100755
--- a/bin/meter_status.py
+++ b/bin/meter_status.py
@@ -50,9 +50,8 @@ def main() :
parser = create_parser()
args, unknown = parser.parse_known_args()
- print "Args = ", args, vars(args)
- print "unknown = ", unknown
- exit(0)
+ # print "Args = ", args, vars(args)
+ # print "unknown = ", unknown
eg = Eagle(**vars(args))
# timeout=45,
@@ -94,9 +93,9 @@ def print_currentsummation(cs) :
if 'TimeStamp' in cs :
time_stamp = to_epoch_1970(cs['TimeStamp'])
print "{0:s} : ".format(time.asctime(time.localtime(time_stamp)))
- print "\tReceived = {0:{width}.3f} Kw".format(reading_received, width=10)
- print "\tDelivered = {0:{width}.3f} Kw".format(reading_delivered, width=10)
- print "\t\t{0:{width}.3f} Kw".format( (reading_delivered - reading_received), width=14)
+ print "\tReceived = {0:10.3f} Kw".format(reading_received)
+ print "\tDelivered = {0:10.3f} Kw".format(reading_delivered)
+ print "\tMeter = {0:10.3f} Kw".format( (reading_delivered - reading_received))
def print_instantdemand(idemand) :
@@ -124,8 +123,8 @@ def print_instantdemand(idemand) :
time_stamp = to_epoch_1970(idemand['TimeStamp'])
print "{0:s} : ".format(time.asctime(time.localtime(time_stamp)))
- print "\tDemand = {0:{width}.3f} Kw".format(reading, width=10)
- print "\tAmps = {0:{width}.3f}".format( ((reading * 1000) / 240), width=10)
+ print "\tDemand = {0:10.3f} Kw".format(reading)
+ print "\tAmps = {0:10.3f}".format( ((reading * 1000) / 240))
#
diff --git a/bin/plot_power.py b/bin/plot_power.py
index 7c48979..89ab525 100755
--- a/bin/plot_power.py
+++ b/bin/plot_power.py
@@ -31,6 +31,10 @@ def main(eg) :
def print_data(eg) :
rh = eg.get_history_data()
#+ # endtime=None, frequency=None) :
+ global curr_day
+
+
+ curr_day = time.gmtime(1);
for dat in rh['HistoryData']['CurrentSummation'] :
print_currentsummation(dat)
@@ -83,11 +87,13 @@ def print_currentsummation(cs) :
#print "\t\tnew max_delta_delivered :", max_delta_delivered
time_struct = time.localtime(time_stamp)
- if curr_day != time_struct.tm_mday :
- curr_day = time_struct.tm_mday
- print "# day_delta_received={0:0.4f}".format(day_delta_received) \
- + "\tday_delta_delivered={0:0.4f}".format(day_delta_delivered) \
- + " : {0:0.4f}".format((day_delta_delivered - day_delta_received))
+ if curr_day.tm_mday != time_struct.tm_mday :
+ curr_day = time_struct
+ print "# {0} day_delta_received={1:0.4f}".format( \
+ time.strftime("%a %Y-%m-%d", curr_day),
+ day_delta_received) \
+ + "\tday_delta_delivered={0:0.4f}".format(day_delta_delivered) \
+ + " : {0:0.4f}".format((day_delta_delivered - day_delta_received))
day_delta_received = 0
day_delta_delivered = 0
diff --git a/setup.py b/setup.py
index 6d8d919..0c11b4f 100644
--- a/setup.py
+++ b/setup.py
@@ -10,38 +10,27 @@ from distutils.core import setup
class install_scripts_and_symlinks(install_scripts):
'''Like install_scripts, but also replicating nonexistent symlinks'''
def run(self):
- print "=============install_scripts_and_symlinks run"
- install_scripts.run(self)
- # Replicate symlinks if they don't exist
- print self
- print "data_files = ", dir( self.distribution.data_files)
- print type(self.distribution.data_files)
- print self.distribution.data_files
- for script in self.distribution.scripts:
- print "\n---script = ",script
- if os.path.islink(script):
- target = os.readlink(script)
- newlink = os.path.join(self.install_dir, os.path.basename(script))
- if not os.path.exists(newlink):
- print "++++++++++", target, " -> ", newlink
- # os.symlink(target, newlink)
+ install_scripts.run(self)
+ # Replicate symlinks if they don't exist
+ for script in self.distribution.scripts:
+ if os.path.islink(script):
+ newlink = os.path.join(self.install_dir, os.path.basename(script))
setup(
name='RainEagle',
- version='0.1.7',
+ version='0.1.7a',
author='Peter Shipley',
author_email='Peter.Shipley@gmail.com',
packages=find_packages(),
scripts=[ 'bin/meter_status.py', 'bin/plot_power.py' ],
- data_files=[ ],
-# ('examples', ['bin/isy_find.py', 'bin/isy_progs.py',
-# 'bin/isy_log.py', 'bin/isy_net_wol.py']),
-# ('bin', ['bin/isy_nodes.py', 'bin/isy_var.py']) ],
+ data_files=[
+ ('examples', ['bin/plot_power.py', 'bin/gnup_poweruse.txt']),
+ ('bin', ['bin/meter_status.py']) ],
url='https://github.com/evilpete/RainEagle',
license='BSD',
description='Python Class for utilizing the Rainforest Automation Eagle ( RFA-Z109 ) socket API.',
- long_description=open('README.md').read(),
+ long_description=open('README.txt').read(),
cmdclass = { 'install_scripts': install_scripts_and_symlinks }
)