Thanks Gary, I ran back through the process to confirm everything would
work as expected. Below is my complete "/home/weewx/bin/user/extensions.py"
for reference.

#
#    Copyright (c) 2009-2015 Tom Keffer <tkef...@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.
"""

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_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'


On Sun, Aug 23, 2020 at 8:35 PM gjr80 <gjroder...@gmail.com> wrote:

> Rob,
>
> weewx.units.obs_group_dict['soilMoist5','soilMoist6','soilMoist7','soilMoist8']
> = 'group_moisture'
>
> may have been accepted by python but it is not correct, it needs to be:
>
> 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'
>
> There is no need to re-run the wee_database commands, just make the
> change to user/extensions.py and restart WeeWX before you use soilMoist5
> to soilMoist8 in any reports.
>
> Gary
> On Monday, 24 August 2020 at 10:28:58 UTC+10 Blaze wrote:
>
>> Thanks Gary, and yes you are correct I did miss the "import
>> schemas.wview_extended".
>>
>> I gave it a try, but I had to make a few adjustments to
>> the "/home/weewx/bin/user/extensions.py" file. Below is the one that seemed
>> to work for me. Or at least I can see my database has been extended! Plus
>> when the report runs, I'm not seeing any errors in the "/var/log/syslog".
>> My extra sensors should arrive in the next day or two, and I will be able
>> to confirm the database is being updated. Is there a way to tell if my
>> sensors belong to "group_moisture", or if what I have done is successful?
>>
>> #
>> #    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.
>> """
>>
>> 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_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','soilMoist6','soilMoist7','soilMoist8']
>> = 'group_moisture'
>>
>> Below is the output to my screen when I ran the --reconfigure command.
>>
>> root@myweewx:~# /home/weewx/bin/wee_database /home/weewx/weewx.conf
>> --reconfigure
>> Using configuration file /home/weewx/weewx.conf
>> Using database binding 'wx_binding', which is bound to database
>> 'archive_sqlite'
>> Copying database 'weewx.sdb' to 'weewx.sdb_new'
>> The new database will use the same unit system as the old ('US').
>> Are you sure you wish to proceed (y/n)? y
>> Database 'weewx.sdb' copied to 'weewx.sdb_new' in 2.92 seconds.
>>
>> And below is my query for the extra sensors in the database.
>>
>> root@myweewx:~# sqlite3 /home/weewx/archive/weewx.sdb_new
>> SQLite version 3.31.1 2020-01-27 19:55:54
>> Enter ".help" for usage hints.
>> sqlite> .headers on
>> sqlite> SELECT dateTime,soilMoist4 FROM archive ORDER BY dateTime ASC
>> LIMIT 5;
>> dateTime|soilMoist4
>> 1596909900|60.0
>> 1596910200|60.0
>> 1596910500|60.0
>> 1596910800|60.0
>> 1596911100|60.0
>> sqlite> SELECT dateTime,soilMoist5 FROM archive ORDER BY dateTime ASC
>> LIMIT 5;
>> dateTime|soilMoist5
>> 1596909900|
>> 1596910200|
>> 1596910500|
>> 1596910800|
>> 1596911100|
>> sqlite> SELECT dateTime,soilMoist6 FROM archive ORDER BY dateTime ASC
>> LIMIT 5;
>> dateTime|soilMoist6
>> 1596909900|
>> 1596910200|
>> 1596910500|
>> 1596910800|
>> 1596911100|
>> sqlite> SELECT dateTime,soilMoist7 FROM archive ORDER BY dateTime ASC
>> LIMIT 5;
>> dateTime|soilMoist7
>> 1596909900|
>> 1596910200|
>> 1596910500|
>> 1596910800|
>> 1596911100|
>> sqlite> SELECT dateTime,soilMoist8 FROM archive ORDER BY dateTime ASC
>> LIMIT 5;
>> dateTime|soilMoist8
>> 1596909900|
>> 1596910200|
>> 1596910500|
>> 1596910800|
>> 1596911100|
>>
>>
>> Thank you for all your help!
>> Rob
>>
>> On Sun, Aug 23, 2020 at 5:21 PM gjr80 <gjrod...@gmail.com> wrote:
>>
>>> 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+...@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
>>> <https://groups.google.com/d/msgid/weewx-user/1c827370-5291-4b7e-aa13-8d51b4ee737cn%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 weewx-user+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/5b542d8e-4eaf-4b59-a329-2d7e72649f48n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/5b542d8e-4eaf-4b59-a329-2d7e72649f48n%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 weewx-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAHmVY1cZ4FrSTakHzDBiLBXjhO3kK9eioM60h%2BMDX-tnLHtpVg%40mail.gmail.com.

Reply via email to