Hello


I have a current cost electricity meter connect to a linux computer via a 
usb cable

On the linux computer is a script that every 20seconds loggs the watt and 
temp readings from the current cost meter to a txt file and RRD file


I can generate the RRD graphs into the weewx public_html directory and 
display them accrodingly


I know that weewx is predominatly for displaying weather data but I would 
like weewx to handle the watt data, so I have tried to save the readings 
into the weewx.sdb 


I found this version of pond.py from the weewx user groups and it works 
with no errors



Following advice given in the weewx help files I can now display the data 
in the various html files display graphs etc


I have one problem, pond.py takes the readings from the first line in the 
txt file (readings.txt)


how do I modify pond.py to take its readings from the last line of the txt 
file, because file the last line of my txt file holds the latest data


thank you for any help


import syslog

import weewx

from weewx.wxengine import StdService


class PondService(StdService):

def __init__(self, engine, config_dict):

super(PondService, self).__init__(engine, config_dict)

d = config_dict.get('PondService', {})

self.filename = d.get('filename', '/var/www/html/data/reading.txt')

syslog.syslog(syslog.LOG_INFO, "pond: using %s" % self.filename)

self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)


def read_file(self, event):

try:

with open(self.filename) as f:

#value = f.read()

line = f.readline()

value = line.split(',')

syslog.syslog(syslog.LOG_DEBUG, "pond: found value of %s" % value)

event.record['ccwatt'] = float(value[0])

event.record['cctemp'] = float(value[1])

except Exception, e:

syslog.syslog(syslog.LOG_ERR, "pond: cannot read value: %s" % e)

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to