diff --git a/Docker/src/bin/tHome-eagle.py b/Docker/src/bin/tHome-eagle.py index f905ff0..f5145c8 100755 --- a/Docker/src/bin/tHome-eagle.py +++ b/Docker/src/bin/tHome-eagle.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #=========================================================================== # @@ -17,9 +17,9 @@ messages. """ import argparse -import bottle as B import sys import json +import bottle as B import tHome as T #=========================================================================== @@ -41,6 +41,15 @@ def instant( client, data, cfg ): return ( cfg.mqttPower, msg ) +#=========================================================================== +def price( client, data, cfg ): + msg = { + "time" : data.TimeUnix, + "price" : data.Price, + "tier" : data.Tier, + } + return ( cfg.mqttPrice, msg ) + #=========================================================================== handlers = { #"BlockPriceDetail" : @@ -51,7 +60,7 @@ handlers = { #"MessageCluster" : #"MeterInfo" : #"NetworkInfo" : - #"PriceCluster" : + "PriceCluster" : price, #"Reading" : #"ScheduleInfo" : #"TimeCluster" : diff --git a/Docker/src/conf/broker.py b/Docker/src/conf/broker.py index d6c2b7c..49b8d7d 100644 --- a/Docker/src/conf/broker.py +++ b/Docker/src/conf/broker.py @@ -6,7 +6,7 @@ import os # #=========================================================================== host = os.getenv('MQTT_BROKER_IP', '192.168.1.20') -port = os.getenv('MQTT_BROKER_PORT', 1883) +port = os.getenv('MQTT_BROKER_PORT', 31333) # Keep alive time in seconds. Client sends a ping if no other message # is sent in this interval. diff --git a/Docker/src/conf/eagle.py b/Docker/src/conf/eagle.py index 8f13f50..1e12b66 100644 --- a/Docker/src/conf/eagle.py +++ b/Docker/src/conf/eagle.py @@ -17,6 +17,12 @@ mqttEnergy = 'power/elec/Home/energy' # Instantaneous power usage topic (reports power usage in W) mqttPower = 'power/elec/Home/power' +#Current price topic (returns current price of electricity from meter) +mqttPrice = 'power/elec/Home/price' + +#Current rate label (returns rate label from meter) +mqttRateLabel = 'power/elec/Home/ratelabel' + #=========================================================================== # # Logging configuration. Env variables are allowed in the file name. diff --git a/Docker/src/python/tHome/test/config.py b/Docker/src/python/tHome/test/config.py index 494bcbb..8d9672f 100644 --- a/Docker/src/python/tHome/test/config.py +++ b/Docker/src/python/tHome/test/config.py @@ -3,4 +3,4 @@ import tHome as T d = T.config.parse( "/home/ted/proj/tHome/conf" ) -print d +print(d) diff --git a/Docker/src/python/tHome/util/Data.py b/Docker/src/python/tHome/util/Data.py index 10f4d76..4d1479e 100644 --- a/Docker/src/python/tHome/util/Data.py +++ b/Docker/src/python/tHome/util/Data.py @@ -11,7 +11,7 @@ class Data: #-------------------------------------------------------------------------- def keys( self ): - return self.__dict__.keys() + return list(self.__dict__.keys()) #-------------------------------------------------------------------------- def update( self, rhs ): @@ -43,7 +43,7 @@ class Data: def _formatValue( self, value, out, indent ): if isinstance( value, Data ): out.write( "%s(\n" % self.__class__.__name__ ) - for k, v in sorted( value.__dict__.iteritems() ): + for k, v in sorted( value.__dict__.items() ): if k[0] == "_": continue @@ -56,7 +56,7 @@ class Data: elif isinstance( value, dict ): out.write( "{\n" ) - for k, v in sorted( value.iteritems() ): + for k, v in sorted( value.items() ): if k[0] == "_": continue diff --git a/Docker/src/python/tHome/util/jsonUtil.py b/Docker/src/python/tHome/util/jsonUtil.py index fe52966..9153498 100644 --- a/Docker/src/python/tHome/util/jsonUtil.py +++ b/Docker/src/python/tHome/util/jsonUtil.py @@ -33,7 +33,7 @@ def loads( text ): #============================================================================= def _toStr( data, ignoreDicts=False ): # Convert unicode to string. - if isinstance( data, unicode ): + if isinstance( data, str ): return data.encode( 'utf-8' ) # For lists, process each item. @@ -45,7 +45,7 @@ def _toStr( data, ignoreDicts=False ): if isinstance( data, dict ) and not ignoreDicts: return { _toStr( k, ignoreDicts=True ) : _toStr( v, ignoreDicts=True ) - for k, v in data.iteritems() + for k, v in data.items() } # Otherwise return the original object. diff --git a/Docker/src/python/tHome/util/net/Poll.py b/Docker/src/python/tHome/util/net/Poll.py index 98dfe6a..4c1b935 100644 --- a/Docker/src/python/tHome/util/net/Poll.py +++ b/Docker/src/python/tHome/util/net/Poll.py @@ -138,7 +138,7 @@ class Poll: # themselves. So make a copy of the dict value list list # containing all the objects so we're not modifying the client # dictionary as we loop over it. - clients = self.clients.values()[:] + clients = list(self.clients.values())[:] for c in clients: c.close() @@ -169,7 +169,7 @@ class Poll: # Returns tuple (fileDescriptor, bitFlag) of the files # that can act. events = self.poll.poll( timeOut_msec ) - except select.error, v: + except select.error as v: # Not sure why, but sometimes with a timeout value, you can # get an "interrupted system call" error thrown. Web # searches indicate this isn't really an error and should be diff --git a/Docker/src/python/tHome/util/test/Data.py b/Docker/src/python/tHome/util/test/Data.py index 722c288..333702d 100644 --- a/Docker/src/python/tHome/util/test/Data.py +++ b/Docker/src/python/tHome/util/test/Data.py @@ -2,18 +2,18 @@ from tHome.util import Data d = Data( a=1, b="asdf", c=2 ) -print d -print "----" +print(d) +print("----") d = Data( a=1, b="asdf", c=[2,3,4] ) -print d -print "----" +print(d) +print("----") d = Data( a=1, b="asdf", c={'a':3, 'b':4} ) -print d -print "----" +print(d) +print("----") d = Data( a=1, b=[ Data(a=1,b=2) ], c={'a':3, 'b':[1,2,3]} ) -print d -print "----" +print(d) +print("----")