Hi,
There are a few ways to add additional data fields to the database, the simplest being to use a currently unused field. The disadvantage is you are stuck with the existing field names and as you say in your case you need more than is currently available. The other approaches involve defining a custom database schema and then using that schema to define your database structure.
When you say that you read the section on adding new types to the database, I presume you mean the
Add a new type to the archive database section in the
Customization Guide. The example given there is fine and quite appropriate if you have written some code (such as in the
electricity.py example) to add extra fields to the loop and/or archive packets/records. What isn't covered is the case where your station/driver already provides the extra data you require but the database has no suitable field(s). In such cases it is unlikely you have some code like
electricity.py so where do you add the code to customize the database? The answer is you add it to the file
user/extensions.py, so given the electricity example mentioned you would simply add the database schema code to
extensions.py as follows:
import locale
# This will use the locale specified by the environment variable 'LANG'
# Other options are possible. See:
# http://docs.python.org/2/library/locale.html#locale.setlocale
locale.setlocale(locale.LC_ALL, '')
import schemas.wview
schema_with_electricity = schemas.wview.schema + [('electricity', 'REAL')]
in your case replace
electricity with whatever field name you want, for multiple fields just duplicate
+ [('electricity', 'REAL')] replacing
electricity with the field name required.
You need to then follow the rest of the steps in the
recipe. Though if you are starting from scratch, once you have completed step 2 (modify wx_binding) you can just delete your existing database then start WeeWX and WeeWX will automatically create the database using your new schema. Steps 3 to 6 actually cover the situation where you are adding fields to an existing database.
I did mention there were other approaches, one is essentially a slight variation of the modified database schema. If you are in the situation of adding many fields to the database it may be simpler and clearer to just define a new schema and tell WeeWX to use that schema. You will find the default WeeWX schema defined in
schemas/wview.py, you can just straight define a new schema in
extensions.py noting that there are a number of mandatory fields (
dateTime,
interval and
usUnits).
Another approach is to leave the WeeWX database as is and utilise a second database for your extra data. This is a more elegant but complex approach that requires a few more python skills. I won't go into it here.
So in summary the following approaches (in order of complexity) are available:
1. utilise existing but unused database fields
2. use a customised database schema by adding to the existing schema
3. use a customised database schema by creating a new schema
4. use a second database
With regards to your units question, I am not sure what exactly you are after. You will find no mention of lightning strikes and (lightning) distance in the table you linked as lightning is not handled natively by WeeWX (but easily added). If you were to add lightning strike counts and lightning distance to WeeWX then they would use the unit groups
group_count and
group_distance respectively. Looking at the table I note that
group_count is not listed, I am not sure why it was omitted, it is not used often but is used for leaf wetness and other unitless obs. Will make sure it is added.
If you were after some other information re lightning units please let us know.
Gary
PS. You will find that the active WeeWX support forums are on Google groups not here.
weewx-user for general user queries and
weewx-development for development related issues. Searching weewx-user should reveal numerous threads regarding customising the database and recording lightning data.