If the predefined unit of a database field changes (i.e. you want it to be changed), weewx needs to be told how to interprete the value stored in this field. Entries in extensions.py will override the default unit definitions weewx keeps in a table at runtime (the obs_group_dict).

E.g.
you have more than 4 soil moisture sensors
SM1 - SM4 you can simply assign to the wsview_extended database field soilMoist1-4 but you have 6 SM sensors and want to use the soilTemp1-2 fields to store the values be it via a field_map_extension or via an assignment in [StdCalibrate] [[Corrections]]

the default unit for SoilTemp1 is degree_celsius - you want it to be percent, you enter in extensions.py
weewx.units.obs_group_dict['soilTemp1'] = 'group_percent'

you have to make an entry for each database field whose unit interpretation you want to change
weewx.units.obs_group_dict['soilTemp2'] = 'group_percent'
as you want to use the database fields SoilTemp1 and SoilTemp2, but don't want °C to be shown in the reports

so it's always the database field name

in the above example - the default unit for soilMoisture1-4 is cb (centibar) which is the unit group "group_moisture" - you may want it to be percent as we did for SM5-6
then you will have to add 4 entries to extensions.py
weewx.units.obs_group_dict['soilMoist1'] = 'group_percent'
weewx.units.obs_group_dict['soilMoist2'] = 'group_percent'
weewx.units.obs_group_dict['soilMoist3'] = 'group_percent'
weewx.units.obs_group_dict['soilMoist4'] = 'group_percent'

If you have only 2 WH51 and want to display their readings in percent, you only need the first two entries

now you should know which field name to put in extensions.py for your WH51 battery status ... 😎

changes in extensions.py become only effective after a restart of weewx !

On 10.08.2023 17:06, Daidl Himself wrote:
Hi,

thats sounds good, and sqlightbrowser tells me the BatterieStatus fiels are empty, most likely a type mismatch as you say. Just wonder, if I map wh51_ch1_batt to /BatteryStatus2/,  I need to mention /BatteryStatus2/ in extension.py. righ?



Rainer Lang schrieb am Donnerstag, 10. August 2023 um 12:51:54 UTC+2:

    in principle all seems to be correct in weewx.conf

    now, how to check the database: get yourself the sqlitebrowser and
    look it up yourself

    sudo apt-get install sqlitebrowser

     you will have to load your database and you can see everything,
    all records etc.

    but you may have a unit problem as the Ecowitt battery status
    comes over either as integer values (0, 1, 2, 3) or as voltage
    e.g. 1.64

    As far as I know Gary has described this in the Ecowitt Gateway WiKi

    therefore the units to be used (which may be different from
    wsview_extended schema) need to be added to
    extensions.py

    https://github.com/gjr80/weewx-gw1000/wiki/Sensor-battery-states

    and make sure you have the respective entries in your extension.py

    e.g.
    weewx.units.obs_group_dict['wh51_ch1_batt'] = 'group_volt'
    weewx.units.obs_group_dict['wn34_ch1_batt'] = 'group_volt'

    and
    weewx.units.obs_group_dict['wh31_ch1_batt'] = 'group_count'
    etc.

    the signal levels should also belong to group_count

    try that ...


    On 10.08.2023 10:48, Daidl Himself wrote:
    Hi,
    I got a GW2000 and several sensors and use them with the gw1000
    driver. So far so good, the most temeratures and stuff is
    automatically logged fine.
    But, I would like to see trends from the battery values as well.
    Searching in the manuals let me learn, the data needs to be
    mapped to a field, either creating new ones, or map to existing
    ones, which are "free". So, I checked the
    "schemas.wview_extended.schema" that is used an made some
    mappings in the weewx.conf:


    /[GW1000]
        # This section is for the Ecowitt Gateway driver.

        # How often to poll the API, default is every 20 seconds:
        poll_interval = 20

        # The driver to use:
        driver = user.gw1000
        ip_address = 192.168.179.113
        port = 45000

        show_all_batt = True

        [[field_map_extensions]]

            extraTemp8 = temp9
            rain = p_rain
            stormRain = p_rainevent
            rainRate = p_rainrate
            dayRain = p_rainday
            weekRain = p_rainweek
            monthRain = p_rainmonth
            yearRain = p_rainyear
            BatteryStatus1 = ws90_batt
            BatteryStatus2 = wh51_ch1_batt
            BatteryStatus3 = wh51_ch2_batt
            BatteryStatus4 = wn34_ch1_batt
    BatteryStatus5 = wh45_batt
    BatteryStatus6 = wh75_ch1_batt
        signal1 = ws90_sig
        signal2 = wh51_ch1_sig
        signal3 = wh51_ch2_sig
        signal4 = wn34_ch1_sig
        signal5 = wh45_sig
        signal6 = wh31_ch1_sig
        signal7 = wh31_ch2_sig
        signal8 = wh31_ch3_sig/

    The Temperature and the rain data is all fine, but the battery
    data can be shown as $latest and $current, but the image
    generator just produced empty fields. Looks for me, as the
    "BatteryStatus" fields are not storred in the database. How can I
    advice this, and how can I check if there are already part of a
    group (I would guess energy would make sense, as the value is Volt)

    thanks a lot by the way, for this fantastic peace of software and
    user friendly documentation.

-- 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/437461fd-ddf9-49c6-a10b-a8ba8737690fn%40googlegroups.com
    
<https://groups.google.com/d/msgid/weewx-user/437461fd-ddf9-49c6-a10b-a8ba8737690fn%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/002dccfa-1e56-4c8d-8cdb-44fbd8e9285cn%40googlegroups.com <https://groups.google.com/d/msgid/weewx-user/002dccfa-1e56-4c8d-8cdb-44fbd8e9285cn%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/241c6d7b-c1b2-30cb-5677-589ec582d05e%40gmail.com.

Reply via email to