Hi Rob,

To take the second part of your question first, I am currently putting 
together a page to go in the GW1000 driver wiki on how to extend the 
Seasons skin to include additional observations such as provided by the 
GW1000 driver. This will also cover adding plots and will complement the 
page re displaying GW1000 sensor battery states in Seasons 
<https://github.com/gjr80/weewx-gw1000/wiki/Adapting-the-Seasons-skin-to-display-battery-states>
.

Now for the db shema. As a general rule of thumb you should *avoid* 
modifying any of the WeeWX files except for weewx.conf, files in 
/home/weewx/bin/user (or /usr/share/weewx/user for package installs) and 
files in the skins directory. Those files/locations are preserved during 
WeeWX upgrades whereas other WeeWX files are liable to be overwritten 
during an upgrade meaning your changes may be lost, or at best may need to 
be re-applied. However, what you want to do can easily be done without 
running foul of future upgrades.

There are two basic ways you can add a new observation to your database, 
first you can re-purpose an existing field. For example, someone with a 
second rain gauge might re-purpose the field hailRate as the rain rate 
field for the second rain gauge. Most easily done if the re-purposed field 
uses the same units as the data you wish to store in the re-purposed field 
but you can essentially use any field. The upside is you don't need to 
change your schema, the downside is it may not be obvious from the field 
name as to what observation is stored in that field.

The second approach is to modify your database schema by adding a new 
field. This is more involved, thought the process is straight forward. 
Adding another field will not substantially increase the size of the 
database or adversely affect performance and I think the benefits of 
self-evident field names count for a lot, especially if you are going to be 
making changes to skins etc to display your data. At the end of the day the 
choice is yours.

I will assume you are going down the second path. The process you need to 
follow is not so much 'modifying wview_extended.py' (remember the rule of 
thumb I mentioned) but rather creating your own schema based on the schema 
in wview_extended.py which you then extend with your new fields. The 
process is covered in Adding a new type to the database 
<http://weewx.com/docs/customizing.htm#add_archive_type> in the 
Customization Guide though you will need to make a couple of slight 
changes. The first change you need to make is instead of inserting the 
lines of code at step 1 in the process in the file user/electricity.py (the 
user directory is in /home/weewx/bin or /usr/share/weewx depending on your 
WeeWX install type), you should add the lines to the end of the special 
file users/extensions.py, something like this (untested):

import schemas.wview_extended

my_schema = { 
    'table': schemas.wview_extended.table + [('soilMoist5', 'REAL')],
    'day_summaries' : schemas.wview_extended.day_summaries + [('soilMoist5', 
'SCALAR')]
}


The second change is that you will need to tell WeeWX what unit group your 
new field belongs to so WeeWX knows what units to use and how to format the 
field in reports. This is done by adding the following to the end of 
user/extensions.py (untested):

import weewx.units

weewx.units.obs_group_dict['soilMoist5'] = 'group_moisture'

Otherwise follow the steps as is and once complete you should find your 
database now includes a field soilMoist5.

Gary

On Thursday, 20 August 2020 12:10:39 UTC+10, Blaze wrote:
>
> I think this is really a multipart question, but I am trying to understand 
> the best/proper way to add Ecowitt soil sensors to my reports. Keeping in 
> mind that I want to be able to upgrade to future releases as they come 
> available with the least amount of post upgrade effort. 
>
> *Setup*
> Ubuntu 20.04.1 LTS
> WeeWx v4.1.1 using setup.py
> gw1000-0.1.0b11
> sqlite db
> Seasons skin
> Ecowitt GW1000 WiFi Gateway
> 1 Outdoor Temp Sensor
> 1 Indoor Temp Sensor
> 5 Soil Moisture Sensors (temporarily 5th sensor is broken while waiting 
> for replacement)  
>
> Out of the box everything is showing up in the Seasons' report except my 
> soil moisture sensors. I do have data for the first 4 soil moisture sensors 
> in the sqlite db, but nothing for 5th one.  And I can see there is no entry 
> in the db for SoilMoisture sensors 5-8. So begins my adventure of learning 
> more about this awesome project called WeeWx.
>
> So I am thinking I have at least 3 tasks.
>
> First I need to extend the db to accommodate SoilMoisture sensors 5-8?
> For this task do I extend the schema by modifying the wview_extended.py 
> and the wview.py to include these extra sensors in the db? Or is the better 
> approach to use something like adding a new type to the database as 
> described in the Customization Guide?
>
> Second modify the reporting mechanism to show SoilMoisture in my Seasons' 
> report.
> I'm really uncertain for this portion. I did a grep in 
> the /home/weewx/bin/ directory, and I can see several files where "soil " 
> is referenced. Do I just need to add entries in these files for extra 
> sensors?
>
> *Command used: *
>     grep -iHR soil /home/weewx/bin/*
>
> *Relevant files (or so I think) referencing the word "soil".*
>     /home/weewx/bin/schemas/wview.py
>     /home/weewx/bin/schemas/wview_extended.py
>     /home/weewx/bin/user/gw1000.py (this one seems to already have all the 
> sensors)
>     /home/weewx/bin/weewx/units.py
>     /home/weewx/bin/weewx/restx.py
>
> And would the last task be to update the appropriate files in 
> the /home/weewx/skins/Seasons/ to actually generate the graphs I want to 
> have displayed in my report?
>
> Thanks in advance for any help or guidance.
> Rob
>
>
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/8dbd5209-bc5e-4f76-9457-c04369eefea6o%40googlegroups.com.

Reply via email to