Tom, in case I would like to create my own database schema, is it enough to just remove the cloumns from the dictionary in this file: .\weewx\bin\schemas\wview.py'' ? Seems like weewx still tries to write to removed database columns when trying to save a record.
Would really appreciate it in case you could name at least some files off the cuff that I have to look into. Thanks :) On Friday, February 15, 2019 at 11:23:00 PM UTC+1, Tom Keffer wrote: > > If you're going to all the trouble of creating a custom database schema, > you can certainly make additional changes to suit your needs. Just be > careful not to drop something you'll need for your reports. > > However, you'll find removing unused observation types does not save as > much space as you think. A major part of the database is the index, which > will still be there. > > As far as what's the best practice? I'd say, do what Google does: save > everything. Storage is cheap. > > -tk > > On Fri, Feb 15, 2019 at 11:50 AM Henry Denston <h.de...@web.de > <javascript:>> wrote: > >> Hi Tom, >> >> thank you very much for your great reply! :) >> I do not have an existing database yet. >> >> I already read the *Adding a new type to the database >> <http://weewx.com/docs/customizing.htm#add_archive_type> *section in the >> Customizing Guide, however was confused as I thought this only applies in >> case one wants to add a new observation type that is not present in weewx >> yet (as in the example electricity). >> I wanted to add additional radiation sources (and there is already the >> radiation observation type implemented in weewx), so I thought by using an >> already existing observation type I might not need to adjust the database >> structure. >> Your answer however, clearly shows how to make the required changes, >> thank you very much! (Maybe add this little example to the docs, right next >> to the electricity eample? :)) >> >> *Another question:* >> By using the file user/extensions.py additional sensors can be added to >> weewx as you have presented. >> Is it best practice to just append additionally required sensors to >> the standard weewx database structure or should I (make some additional >> changes to) 'rebuild' the used database structure for my system? >> For example in case I intend to use only about 8 sensors/values in my >> current system (e.g.: dateTime, usUnits, windSpeed, outTemp, radiation, >> radiation1, radiation2, radiation3) I could remove all additional values in >> the database that I will not use (e.g. barometer, pressure, altimeter, >> inTemp, etc....) ? Would love to hear your opinion on that. >> >> Thank you very much, Henry. >> >> >> On Friday, February 15, 2019 at 7:51:13 PM UTC+1, Tom Keffer wrote: >>> >>> Yes, your strategy would work, and your names (radiation1, radiation2, >>> and radiation3) are sensible names to give the extra sensors. >>> >>> You would have to change the database schema to accommodate the extra >>> sensors. >>> >>> Do you have an existing database, to which you want to add the new >>> observation types? If so, then follow the instructions in the Customizing >>> Guide, section *Adding a new type to the database >>> <http://weewx.com/docs/customizing.htm#add_archive_type>*. If there is >>> something that is confusing about the instructions, let us know what the >>> problem is so we can clarify and, perhaps, update the documents and make it >>> clearer. >>> >>> If you do not have an existing database, then it is slightly easier. To >>> the bottom of the file user/extensions.py, add the following: >>> >>> import schemas.wview >>> radiation_schema = schemas.wview.schema + [ >>> ('radiation1'', 'REAL'), >>> ('radiation2'', 'REAL'), >>> ('radiation3'', 'REAL'), >>> ] >>> >>> Then go into your weewx.conf and change the [DataBindings] and >>> [Databases] section so they look like this: >>> >>> [DataBindings] >>> >>> [[wx_binding]] >>> # The database must match one of the sections in [Databases]. >>> # This is likely to be the only option you would want to change. >>> database = archive_sqlite >>> # The name of the table within the database >>> table_name = archive >>> # The manager handles aggregation of data for historical summaries >>> manager = weewx.wxmanager.WXDaySummaryManager >>> # The schema defines the structure of the database. >>> # It is *only* used when the database is created. >>> schema = user.extensions.radiation_schema >>> >>> ############################################################################## >>> >>> # This section defines various databases. >>> >>> [Databases] >>> >>> # A SQLite database is simply a single file >>> [[archive_sqlite]] >>> database_name = radiation.sdb >>> database_type = SQLite >>> >>> # MySQL >>> [[archive_mysql]] >>> database_name = weewx >>> database_type = MySQL >>> >>> Restart WeeWX. >>> >>> WeeWX will now use the new database radiation.sdb, which will have the >>> new SQL columns. >>> >>> -tk >>> >>> >>> >>> On Fri, Feb 15, 2019 at 8:51 AM Henry Denston <h.de...@web.de> wrote: >>> >>>> Hello everyone! >>>> >>>> I'm currently developing a custom weather station (a microcontroller >>>> collecting data from custom sensors and forwarding it to a RaspberryPi). >>>> I already read the customization guide multiple times and started to >>>> develop a custom weewx-driver for my custom weather station. >>>> The customization guide offers some very valuable insights. However, I >>>> still have some questions and misunderstandings I guess, so I hope some >>>> experienced users/developers can help me out. :) >>>> >>>> As already stated I started developing my own driver, I also edited the >>>> weewx.conf and my custom driver is loaded when I start weewx with: sudo >>>> ./bin/weewxd weewx.conf (it yields/prints packets) >>>> I checked the sql table structures in the documentation and now I'm not >>>> sure how to save my custom sensors values. >>>> For example: I have a windsensor (measuring windspeed only), a >>>> temperature sensor and 4 pyranometer sensors of different kind measuring >>>> the sun irradiation. >>>> Now in my custon driver I know that I can store/assign the windspeed >>>> and temperature like this for example: >>>> >>>> data = dict() >>>> >>>> >>>> data['dateTime'] = int(data_array[0]) # unix timestamp >>>> data['usUnits'] = weewx.METRIC >>>> data['windSpeed'] = float(data_array[1]) # Anemometer measuring windspeed >>>> only >>>> data['outTemp'] = float(data_array[0]) # PT100 measuring temperature >>>> outside >>>> >>>> >>>> yield data >>>> >>>> >>>> So this should be straight forward if I understand correctly. >>>> But how do I store my irradiation values from the various pyranomerters? >>>> >>>> It seems that in the expected database structure there is only one >>>> column for irradiation available. >>>> How can I store it so WeeWx can use it in its reports and archives? >>>> I have smth. like this in mind: >>>> >>>> data['radiation'] = float(dataset_array_sensor[2]) # pyranometer 1 >>>> data['radiation1'] = float(dataset_array_sensor[3]) # pyranometer 2 >>>> data['radiation2'] = float(dataset_array_sensor[4]) # pyranometer 3 >>>> data['radiation3'] = float(dataset_array_sensor[5]) # pyranometer 4 >>>> >>>> >>>> Would this work? >>>> Do I have to change the sql database structure for it to work? (I plan >>>> to use sqlite for it as its easier to use it out of the box) >>>> If so, how would I do it? >>>> >>>> I did read the customization guide multiple times but I'm really >>>> confused regarding this. >>>> I hope you can give me a hint into the right direction (I think I'm >>>> probably way overthinking this and just missing a small detail) >>>> Thank you very much in advance! :) >>>> >>>> Best regards, Henry. >>>> >>>