I have read "create a custom service" and "add a new type to the database" and am ready to start but I'd like you to clarify for me a couple things. When you wrote the example using electricity from a meter as the example, did you intend for this to pertain to only one parameter? Reason I ask is because you use the word Type, of which there could be multiple instances of that type, i.e. kilowatthours used to date (the 'meter reading'), and possibly other parameters like supply voltage rms, etc. So does the example here infer that only one parameter is being added? Then when you get to the Add a new type to our existing schema, are you adding a type which can be implemented in more than one field in the weewx.sdb, or, is it only to add a single parameter (i.e. 'field') and I have to do it again to add two separate fields (am I using the right term 'field'?)
Let me explain what I need to do. I have my maxbotix distance sensor working with some python code to read the serial stream, do some simple calculations, and save the results to a file. I noticed Matt has a package on Github for this however I cannot use that method, I need to take about 20 seconds worth of rapidfire measurements into a buffer, sort the buffer and average it so I can get Average and Difference which will be used to obtain Lake Height Elevation (known precise elevation of sensor minus distance, then converted to decimal feet), and to obtain Wave height (simply the max minus min of that reading sequence), theoretically dealing with wind and boat waves on the lake. All this is done independent of weewx so it doesn't slow weewx down.
In the electricity example it states where "(code that downloads the consumption data from the connection to the meter goes here)" the execution of that code should take no more than a couple seconds max. So I run my mb.py code via cron every xx minutes and it writes out a 2-parameter file mbdata.dat. At this point in the example:
def new_archive_packet(self, event):
(code that downloads the consumption data from the connection to the meter)
event.record['electricity'] = retrieved_value
I will have simple python code that reads those two values from mbdata.dat and puts them into two variables for later use in weewx, i.e. writing it in the archive and the reports, and that open/read/close should be very quick.
However here is where I am not clear. I'll have two measurements, LakeElevation (decimal feet) and WaveHeight (decimal inches).
In the next steps in what is shown in the Customization guide, I have to create two new fields (why are they called 'types'?) in the schema? I want to do this as smoothly as possible, and haven't done it before.
Hopefully the rest should go smoothly but first I want to make sure I'm getting those two added to the schema and archived properly.
Thank you for clarifying.
My code for my maxbotix read of NUM_READS from ttyAMA0 isn't pretty but it works quite well and a minimum amount of time is wasted between each read so the sensor's output is as continuous as possible. If anyone needs it I'll share.
Phil