4.2.0 simulator - bug & fix for configuring list of observations

31 views
Skip to first unread message

Graham Eddy

unread,
Dec 25, 2020, 10:58:28 PM12/25/20
to weewx...@googlegroups.com
hello tom,
hopefully a simple fix that can make it into 4.3.0...

problem:
weewx 4.2.0 simulator crashes when i specify the list of observations to include

weewx.conf extract:
(note: ‘observations = ‘ line is one line. the line break is an artifact of copy&paste)
[GeSimulator]
    # This section is for the weewx weather station simulator

    # The time (in seconds) between LOOP packets.
    loop_interval = 2.5

    # The simulator mode can be either 'simulator' or 'generator'.
    # Real-time simulator. Sleep between each LOOP packet.
    mode = simulator
    # Generator.  Emit LOOP packets as fast as possible (useful for testing).
    #mode = generator

    # The start time. Format is YYYY-mm-ddTHH:MM. If not specified, the default 
    # is to use the present time.
    #start = 2011-01-01T00:00

    # list of variables for simulator to generate.
    # note: if this is specified, only these will be produced
    # remove PM2.5 and AQI variables
    observations = inTemp,barometer,pressure,windSpeed,windDir,windGust,windGustDir,outHumidity,inHumidity,radiation,UV,rain,txBatteryStatus,windBatteryStatus,rainBatteryStatus,outTempBatteryStatus,inTempBatteryStatus,consBatteryVoltage,heatingVoltage,supplyVoltage,referenceVoltage,rxCheckPercent,altOutTemp,altInTemp,altPressure,altWindSpeed,altWindDir,altWindGust,altWindGustDir,altOutHumidity,altInHumidity,altRain,luminosity,solarEnergy,soilMoist1,soilMoist2,riverLevel,extraTemp1,wh40_batt,wh41_ch1_batt,wh41_ch2_batt,wh51_ch1_batt,wh51_ch2_batt,wh57_batt,ws80_batt

    # The driver to use:
    driver = user.gesimulator

log extract:
Dec 26 14:01:36 dizzy weewx-test[332] CRITICAL weewx.engine:     ****    File "/opt/weewx-4.2.0-test/bin/weewx/drivers/simulator.py", line 139, in __init__
Dec 26 14:01:36 dizzy weewx-test[332] CRITICAL weewx.engine:     ****      self.trim_observations(stn_dict)
Dec 26 14:01:36 dizzy weewx-test[332] CRITICAL weewx.engine:     ****    File "/opt/weewx-4.2.0-test/bin/weewx/drivers/simulator.py", line 144, in trim_observations
Dec 26 14:01:36 dizzy weewx-test[332] CRITICAL weewx.engine:     ****      desired = [x.strip() for x in stn_dict['observations'].split(',')]
Dec 26 14:01:36 dizzy weewx-test[332] CRITICAL weewx.engine:     ****  AttributeError: 'list' object has no attribute 'split'
Dec 26 14:01:36 dizzy weewx-test[332] CRITICAL __main__: Unable to load driver: 'list' object has no attribute 'split'

rationale:
clearly the ‘observations =‘ line has been parsed as a list not as a string so split() fails

suggested fix:
weewx.drivers.simulator replace line 144 from
            desired = [x.strip() for x in stn_dict['observations'].split(',')]
to
            desired = stn_dict['observations']
            if isinstance(desired, str):
                # convert comma-separated string to list
                desired = [x.strip() for x in desired.split(',')]

cheers

Tom Keffer

unread,
Dec 26, 2020, 7:43:00 AM12/26/20
to weewx-user
Fixed in commit d9a4daa

Thanks, Graham!

-tk

--
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/419112CF-BA4B-4B03-B7E3-E07B95F04DEA%40gmail.com.

Graham Eddy

unread,
Dec 26, 2020, 7:51:02 AM12/26/20
to weewx...@googlegroups.com
i tried sending a pull request for [[calculations]] change - did that arrive?
i also then tried re-sending the simulator fix as a pull request but following the same procedure in github didn’t find a change to send - did that get gobbled into the other pull request somehow?
github is all strange to me...

On 26 Dec 2020, at 11:42 pm, Tom Keffer <tke...@gmail.com> wrote:

Fixed in commit d9a4daa

Reply all
Reply to author
Forward
0 new messages