except ValueError:
return None
- def __init__(self, min, hour, day, month, year, cost, amps):
+ def __init__(self, min, hour, day, month, year, amps):
self.__sec = 0 #The CM160 does not return seconds in it's data
#stream.
self.__min = min
# to 0x49. Not sure why but I'll mask them out
# so that we don't get invalid month errors.
self.__year = year
- self.__costPerKWH = cost
+# self.__costPerKWH = cost
self.__amps = amps
self.__realTime = False #Changes to True when realtime data is being read
def getSecond(self):
return self.__sec
- def getCostPerKWH(self):
- return self.__costPerKWH
+# def getCostPerKWH(self):
+# return self.__costPerKWH
def getAmps(self):
return self.__amps
def __str__(self):
"""Return the object as a string"""
- s="%s %f %f" % (self.getDateStr(), self.__amps, self.__costPerKWH)
+ s="%s %f " % (self.getDateStr(), self.__amps)
if self.__month >= 1 and self.__month <= 12:
return s
#The CM160 sometime returns a month greater than 12. As I don't know how to
if len(elems) == 4:
try:
self.__amps = float(elems[2])
- self.__costPerKWH = float(elems[3])
+# self.__costPerKWH = float(elems[3])
t = elems[0]
d = elems[1]
dateElems = d.split("/")
day = frame[3]
hour = frame[4]
_min = frame[5]
- costPerKWH = (frame[6]+(frame[7]<<8))/100.0 #Cost in pence per kWh
+# costPerKWH = (frame[6]+(frame[7]<<8))/100.0 #Cost in pence per kWh
amps = (frame[8]+(frame[9]<<8))* 0.07 #Conversion factor to Amps
- cm160Data = CM160Data(_min, hour, day, month, year, costPerKWH, amps)
+ cm160Data = CM160Data(_min, hour, day, month, year, amps)
#Set flag to indicate if this CM160Data was read in realtime or during a data download
cm160Data.setRealTime(realTimeData)
heappush(self.__queue, cm160Data) # read data from the queue by, cm160Data = heappop(self.__queue)
"""
conn, cursor = self.__connect()
try:
- cursor.execute("CREATE TABLE cm160data(ts timestamp, current float, tariff float, UNIQUE (ts))")
+ cursor.execute("CREATE TABLE cm160data(ts timestamp, current float, UNIQUE (ts))")
# Attempt to create table in case this is first time to run
# the server; but thereafter we expect an exception because the
# create will fail...
stored=False
try:
- self.__StoreCursor.execute("""INSERT INTO cm160data VALUES (%s,%s,%s)""", (cm160Data.getDatetime(),cm160Data.getAmps(),cm160Data.getCostPerKWH(),))
+ self.__StoreCursor.execute("""INSERT INTO cm160data VALUES (%s,%s)""", (cm160Data.getDatetime(),cm160Data.getAmps(),))
stored=True
except MySQLdb.Error as e: