I see. The schema is only used when the database is *created*. So, if you're using an existing database, it doesn't matter what you put there.
If you do not have an existing database, then it will be used. However, because you're using a type that's already in the wview schema, leafTemp1, then there is no need to add a new type. Personally, if I didn't have an existing database, I would add the new type: it's easier to tell what that observation type is, rather than remembering that leafTemp1 is actually, say, "tank level." Where it is really useful to recycle a name such as leafTemp1 is if you have an existing database and you don't want to go to the trouble of rebuilding it with a new type. Then reusing a name is a lot easier. Hope that's clear. -tk On Mon, Apr 13, 2020 at 6:51 AM Messy Potamia <[email protected]> wrote: > I didn't have any problem reading the data in via my existing python code > (although I suspect your sample may be cleaner, I'll try that too). > What I was concerned with is the schema *** = schema *** + schema ***. > Since I'm not extending this schema, I commented out that line. Added the > service to weewx.conf, restarted weewx w/ debug=1, saw it add the service > (and now the new .pyc exists in user), and it's reading the data into > weewx.sdb. Now it's a simple matter of editing my skins to add the > parameter. > Thanks --Phil > > On Monday, April 13, 2020 at 2:42:05 PM UTC+2, Thomas Keffer wrote: >> >> You want something like: >> >> with open('/path/to/file') as f: >> value = f.readline().strip() >> event.record['leafTemp1'] = float(value) if value != '' else None >> >> Or, use filepile <https://github.com/tkeffer/filepile>, although that >> would require you to change the format of your data file. >> >> -tk >> >> On Mon, Apr 13, 2020 at 4:35 AM Messy Potamia <[email protected]> >> wrote: >> >>> I want to read in a single %2.2f from a file "special.dat" and store it >>> in something I'll never otherwise use, "leafTemp1". >>> >>> My weewx is 3.6.2. I have read the suggestion to use a 2nd database, >>> however I do not want to do that. I have written a custom .py before to >>> read data from a 2-element data file, but I extended the schema to do that >>> (and I remember Tom asking why, and it was because I thought that was the >>> thing to do, anyway I don't want to do that this time) >>> >>> pi@RPI3:~ $ cat /home/weewx/special.dat >>> 32.67 >>> pi@RPI3:~ $ >>> >>> Here is the python I copied & modified a few years ago, which works for >>> that system: >>> #!/usr/bin/env python >>> >>> #file user/lakedata.py >>> import weewx >>> from weewx.engine import StdService >>> >>> class AddLakedata(StdService): >>> >>> def __init__(self, engine, config_dict): >>> # Initialize my superclass first: >>> super(AddLakedata, self).__init__(engine, config_dict) >>> # Bind to any new archive record events: >>> self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_packet) >>> >>> def new_archive_packet(self, event): >>> >>> #(code that reads two measurements from a file) >>> with open("/mnt/wxdata/weewxmbdata.dat") as f: >>> for line in f: >>> numbers_str = line.split() >>> numbers_float = [float(x) for x in numbers_str] >>> value1 = numbers_float[0] >>> value2 = numbers_float[1] >>> >>> event.record['lakeElevation'] = value1 >>> event.record['lakeWaveheight'] = value2 >>> >>> import schemas.wview >>> schema_with_lakedata = schemas.wview.schema + [('lakeElevation', 'REAL' >>> )] + [('lakeWaveheight', 'REAL')] + [('lightning', 'REAL')] >>> >>> # >>> >>> The above code works fine on a previous installation and I'm not going >>> to mess with it. This install however, I will be reading a single value, >>> and applying it into an existing field in the default existing database. My >>> concern is, in the above lakedata.py, which represents an extended schema, >>> what changes when I'm using the existing schema? >>> >>> Thanks for clarifying this for me. >>> >>> Phil >>> >>> -- >>> 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 [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/weewx-user/a7495c2d-f450-46cf-a88f-c75e696f1940%40googlegroups.com >>> <https://groups.google.com/d/msgid/weewx-user/a7495c2d-f450-46cf-a88f-c75e696f1940%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/72175d38-5066-4fc8-94fe-51ceba7af339%40googlegroups.com > <https://groups.google.com/d/msgid/weewx-user/72175d38-5066-4fc8-94fe-51ceba7af339%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEASS8QwJ3KB3iwGSWE3kYM%3DG647c2r4idtZqWy8UiWuWQ%40mail.gmail.com.
