-
Notifications
You must be signed in to change notification settings - Fork 8
Changes to 24 hour average particulate concentration field names
The GW1000 driver uses a default field map to map internal GW1000 driver fields to WeeWX loop packet fields. The default field map exists within the GW1000 driver and maps all available GW1000 fields to a WeeWX loop packet field. Whilst users cannot alter the default field map, they can alter the field map used by the GW1000 driver though use of the [[field_map]]
and [[field_map_extensions]]
stanzas under [GW1000]
in weewx.conf
. Field map entries are in the format:
WeeWX field name = GW1000 internal field name
Unless an equivalent WeeWX field name exists, in most cases the default field map maps the internal GW1000 field to a WeeWX loop packet field of the same name. The GW1000 driver v0.1.0 default field map includes mappings of the following 24 hour average particulate concentration fields:
pm2_51_24hav = pm251_24hav
pm2_52_24hav = pm252_24hav
pm2_53_24hav = pm253_24hav
pm2_54_24hav = pm254_24hav
As of the GW1000 driver v0.2.0 the internal 24 hour average particulate concentration field names have changed as have the corresponding WeeWX loop packet field names used in the default field map. The net result of these changes is that when used with the default field map the v0.2.0 GW1000 driver will emit different loop packet field names to v0.1.0 for 24 hour average particulate concentration fields. For example, under v0.1.0 the GW1000 driver may emit a field pm2_51_24hav
, under v0.2.0 that same system would emit the same data in field pm2_51_24h_avg
.
The GW1000 driver v0.2.0 default field map includes the following mappings of 24 hour average particulate concentration fields:
pm2_51_24h_avg = pm251_24h_avg
pm2_52_24h_avg = pm252_24h_avg
pm2_53_24h_avg = pm253_24h_avg
pm2_54_24h_avg = pm254_24h_avg
pm2_55_24h_avg = pm255_24h_avg
pm10_24h_avg = pm10_24h_avg
co2_24h_avg = co2_24h_avg
Note: The GW1000 driver v0.2.0 supports additional 24 hour average particulate concentration fields available via the WH45 sensor.
You are only affected by this change if you have one or more sensors that emit 24 hour average particulate concentration data (at time of writing the only sensors that emit 24 hour average particulate concentration data are WH41, WH43 or WH45) and have:
- used the 24 hour average particulate concentration data in WeeWX reports via a
$current
tag, eg$current.pm2_52_24hav
; or - used the 24 hour average particulate concentration fields in a GW1000 driver field map or field map extension; or
- saved 24 hour average particulate concentration data to database.
Otherwise you are unaffected and you can simply install the GW1000 driver v0.2.0 over the v0.1.0 driver and need take no further action.
If you are affected by the change in field names the action you need to take depends on how you are using the 24 hour average particulate concentration data.
If you are only using the 24 hour average particulate concentration data in WeeWX reports with one or more $current
tags you have two options:
-
Amend the tags used in the reports concerned to use the new WeeWX field names, eg change
$current.pm2_51_24hav
to$current.pm2_51_24h_avg
. -
Leave any $current
tags as is but alter the field map used by the *GW1000 driver* to map the new GW1000 internal field name to the old WeeWX field name through use of the
[GW1000]stanza in
weewx.conf`, eg:[GW1000] ... [[field_map_extensions]] pm2_51_24hav = pm2_51_24h_avg
If you are using the 24 hour average particulate concentration fields in a GW1000 driver field map or field map extension entry you should alter your field map and/or field map extension entries to use the v0.2.0 GW1000 driver internal fields, eg if you use the following:
[GW1000]
...
[[field_map_extensions]]
my_weewx_field = pm251_24hav
you would change it to:
[GW1000]
...
[[field_map_extensions]]
my_weewx_field = pm251_24h_avg
If you have saved 24 hour average particulate concentration data to database you have two options:
-
Add field map extension entries to map the new internal GW1000 driver field(s) to your v0.1.0 WeeWX field names; for example, if you were saving
pm2_51_24hav
to database you might add the following field map extension:[GW1000] ... [[field_map_extensions]] pm2_51_24hav = pm2_51_24h_avg
-
Modify your database schema to change any 24 hour average particulate concentration fields used in the database schema to use the v0.2.0 field names. This will involve a number of steps:
Note: The user may find it useful to first revise the Customizing the database section of the Customization Guide.
-
Stop WeeWX
-
Rename the archive table field(s) concerned. This can be accomplished under
SQLite
orMySQL/MariaDB
using theALTER TABLE ... RENAME COLUMN
SQL command. For example, if thepm2_51_24hav
field was being saved to database you would rename thepm2_51_24hav
column in the archive table using the following command:ALTER TABLE archive RENAME COLUMN pm2_51_24hav TO pm2_51_24h_avg;
-
Modify the existing user code that details the (previously modified) database schema. For example, if the following code was included in
BIN/user/extensions.py
to specify the previously modified schema:import schemas.wview_extended my_schema = { 'table': schemas.wview_extended.table + [('pm2_51_24hav', 'REAL')], 'day_summaries' : schemas.wview_extended.day_summaries + [('pm2_51_24hav', 'SCALAR')] }
it would need to be changed to:
import schemas.wview_extended my_schema = { 'table': schemas.wview_extended.table + [('pm2_51_24h_avg', 'REAL')], 'day_summaries' : schemas.wview_extended.day_summaries + [('pm2_51_24h_avg', 'SCALAR')] }
Note: There are a number of different ways to specify changes to the database schema, the example above is but one way. Users wishing to again modify their database schema to use the v0.2.0 field names should again modify whatever code was originally used to modify their database schema.
-
Drop the daily summary tables:
$ wee_database --drop-daily
-
Rebuild the daily summary tables:
$ wee_database --rebuild-daily
-
Restart WeeWX