Skip to content

Changes to 24 hour average particulate concentration field names

gary edited this page Aug 9, 2023 · 5 revisions

Changes to 24-hour average particulate concentration field names

Introduction

The Ecowitt gateway driver uses a default field map to map internal Ecowitt gateway driver fields to WeeWX loop packet fields. The default field map exists within the Ecowitt gateway driver and maps all available gateway device fields to a WeeWX loop packet field. Whilst users cannot alter the default field map, they can alter the field map used by the Ecowitt gateway 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 = Ecowitt gateway driver internal field name

Unless an equivalent WeeWX field name exists, in most cases the default field map maps the internal Ecowitt gateway driver field to a WeeWX loop packet field of the same name. The Ecowitt gateway 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

The changes

As of the Ecowitt gateway 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 Ecowitt gateway driver v0.2.0 will emit different loop packet field names to the v0.1.0 driver for 24-hour average particulate concentration fields. For example, under v0.1.0 the Ecowitt gateway driver may emit a field pm2_51_24hav, whereas under v0.2.0 that same system would emit the same data in field pm2_51_24h_avg.

The Ecowitt gateway 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 Ecowitt gateway driver v0.2.0 supports additional 24-hour average particulate concentration fields available via the WH45 sensor.

Am I affected

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 release of v0.2.0 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 an Ecowitt gateway driver field map or field map extension; or
  • saved 24-hour average particulate concentration data to database.

Otherwise you are unaffected and can simply install the Ecowitt gateway driver v0.2.0 over the v0.1.0 driver and take no further action.

What to do if I am affected

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.

I am using 24-hour average particulate concentration data with a $current tag

If you are using the 24-hour average particulate concentration data in WeeWX reports with one or more $current tags you have two options:

  1. 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.

  2. Leave any $current tags as is but alter the field map used by the Ecowitt gateway driver to map the new Ecowitt gateway driver internal field name to the old WeeWX field name through use of the [GW1000] [[field_map_extensions]] stanza in weewx.conf, eg:

    [GW1000]
        ...
        [[field_map_extensions]]
            pm2_51_24hav = pm2_51_24h_avg           
    
I am using 24-hour average particulate concentration fields in a custom field map

If you are using the 24-hour average particulate concentration fields in a Ecowitt gateway 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 Ecowitt gateway 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
I am saving 24-hour average particulate concentration data to database

If you have saved 24-hour average particulate concentration data to database you have two options:

  1. Add field map extension entries to map the new internal Ecowitt gateway 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
    
  2. 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) and daily summary tables concerned. If using WeeWC v4.5.0 or later the preferred method of achieving this is to use the wee_database utility with the --rename-column action. Alternatively, users that are comfortable with SQL commands can rename the necessary columns and tables from the command line using sqlite3 or MySQL/MariaDB as applicable.

  • Modify the existing user code that details the (previously modified) database schema. For example, if the following code was included in 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.

  • Restart WeeWX