Looks good though you have missed an import:

import schemas.wview_extended

needs to be included in extensions.py before you create my_schema. Not sure 
if it’s a typo/formatting issue or not but the group assignment statements 
need to be on separate lines, python will complain otherwise.

Also, when running wee_database you may or may not need to prefix 
wee_database with sudo, it will depend on you system/WeeWX install. Try it 
without, if you get an error try it with.

Gary

On Monday, 24 August 2020 at 02:35:12 UTC+10 Blaze wrote:

> Thank you both Graham and Gary! Would either of you or someone else mind 
> reviewing my proposed steps?
>
> In reading the Adding a new type to the database 
> <http://weewx.com/docs/customizing.htm#add_archive_type>, and what you 
> have both provided, I think I have a good understanding except for the 4th 
> step. Below are the steps I think I need to follow. 
>
> *Step 1.*
> Stop WeeWX
>
> /etc/init.d/weewx stop
>
>
> *Step 2.*
> Make a backup of the sqlite database
>
> cp /home/weewx/archive/weewx.sdb 
> /home/weewx/archive/weewx.sdb.bkup08232020a
>
>
> *Step 3.*
> Edit the "/home/weewx/bin/user/extensions.py" file.
>
> #
> #    Copyright (c) 2009-2015 Tom Keffer <tke...@gmail.com>
> #
> #    See the file LICENSE.txt for your full rights.
> #
>
> """User extensions module
>
> This module is imported from the main executable, so anything put here 
> will be
> executed before anything else happens. This makes it a good place to put 
> user
> extensions.
>
> """
> my_schema = {
>                 'table': schemas.wview_extended.table + [
>                     ('soilMoist5', 'REAL'),
>                     ('soilMoist6', 'REAL'),
>                     ('soilMoist7', 'REAL'),
>                     ('soilMoist8', 'REAL')
>                     ],
>
>                 'day_summaries' : schemas.wview_extended.day_summaries + 
> [('soilMoist5','scalar'),('soilMoist6','scalar'),('soilMoist7','scalar'),('soilMoist8',
>  
> 'scalar')]
>
> import weewx.units
>
>                 weewx.units.obs_group_dict['soilMoist5'] = 
> 'group_moisture' weewx.units.obs_group_dict['soilMoist6'] = 
> 'group_moisture' weewx.units.obs_group_dict['soilMoist7'] = 
> 'group_moisture' weewx.units.obs_group_dict['soilMoist8'] = 'group_moisture'
>
> 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, '')
>
>
> *Step 4.*
> Change the line "schema = schemas.wview_extended.schema" to "schema = 
> user.extensions.my_schema" for the [[wx_binding]] option under 
> the [DataBindings] in my "/home/weewx/weewx.conf" file.
>
> [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.manager.DaySummaryManager
>         # The schema defines the structure of the database.
>         # It is *only* used when the database is created.
>         #schema = schemas.wview_extended.
> *schema = user.extensions.my_schema*
>     [[forecast_binding]]
>         manager = weewx.manager.Manager
>         schema = user.forecast.schema
>         table_name = archive
>         database = forecast_sqlite
>
>
> *Step 5.*
> Run the following command to create and populate the new database.
>
> /home/weewx/bin/wee_database /home/weewx/weewx.conf --reconfigure
>
>
> *Step 6.*
> Replace the old database with the one created in Step 5.
>
> mv /home/weewx/archive/weewx.sdb_new /home/weewx/archive/weewx.sdb
>
>
> *Step 7.*
> Start WeeWX
>
> /etc/init.d/weewx start
>
>
> Thanks again!
> Rob
>
> On Fri, Aug 21, 2020 at 11:51 PM Graham Eddy <graha...@gmail.com> wrote:
>
>> more like (and watch your commas, semicolons and case):
>>
>> import schemas.wview_extended
>>
>> my_schema = { 
>>     'table': schemas.wview_extended.table + [
>>       ('soilMoist5', 'REAL’),      ('soilMoist6', 'REAL’),      
>> ('soilMoist7', 'REAL’),      ('soilMoist8', 'REAL')
>> ],
>>     'day_summaries' : schemas.wview_extended.day_summaries + 
>> [('soilMoist5’,’scalar’),(‘soilMoist6’,’scalar’),(‘soilMoist7’,’scalar’),('soilMoist8',
>>  ’scalar')]
>> }
>>
>> import weewx.units
>>
>> weewx.units.obs_group_dict[‘soilMoist5’] = ‘group_moisture’ 
>> weewx.units.obs_group_dict[‘soilMoist6’] = ‘group_moisture’ 
>> weewx.units.obs_group_dict[‘soilMoist7’] = ‘group_moisture’ 
>> weewx.units.obs_group_dict['soilMoist8'] = 'group_moisture'
>>
>>
>> -- 
>> 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+...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/7069D2C1-0BEE-4008-8C71-3D282A27220A%40gmail.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/7069D2C1-0BEE-4008-8C71-3D282A27220A%40gmail.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 weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/1c827370-5291-4b7e-aa13-8d51b4ee737cn%40googlegroups.com.

Reply via email to