poblabs / weewx-belchertown

A clean and modern weewx skin with real time streaming updates, forecast data and interactive charts. View it in action at BelchertownWeather.com
https://belchertownweather.com
GNU General Public License v3.0
208 stars 111 forks source link

Fail skin load in weewx 4.6.0 #761

Closed dtalens closed 2 years ago

dtalens commented 2 years ago

First step

Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine: Caught unrecoverable exception in generator 'user.belchertown.HighchartsJsonGenerator'
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****  invalid literal for int() with base 10: '%'
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****  Traceback (most recent call last):
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****    File "/usr/share/weewx/weewx/reportengine.py", line 197, in run
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****      obj.start()
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****    File "/usr/share/weewx/weewx/reportengine.py", line 378, in start
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****      self.run()
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****    File "/usr/share/weewx/user/belchertown.py", line 2714, in run
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****      series_data = self.get_observation_data(
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****    File "/usr/share/weewx/user/belchertown.py", line 3726, in get_observation_data
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****      usage_round = int(
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****  ValueError: invalid literal for int() with base 10: '%'
Feb  6 07:41:24 minipc weewx[45742] ERROR weewx.reportengine:         ****  Generator terminated

Describe the bug Load skin fail after update weewx version 4.6.0 but I kept my weew.conf file. I downgraded to previous version 4.5.1

Link to your website (IMPORTANT) https://meteopego.com

Version of the skin you're using 1.3.1b

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Device Information (please complete the following information):

Additional context Add any other context about the problem here. Maybe a potential fix?

HELP WANTED If you have a fix for this, please submit a pull request against the development branch!

James-76 commented 2 years ago

Interesting - I just upgraded to 4.6.0 to see what would happen and it appears to be running fine on my website https://blisteringbarnacles.co.uk/

wget http://weewx.com/downloads/weewx-4.6.0.tar.gz
tar xvfz weewx-4.6.0.tar.gz
cd weewx-4.6.0
python3 ./setup.py build
sudo python3 ./setup.py install

/home/weewx# diff weewx.conf weewx.conf.20220208215340
26c26
< version = 4.6.0
---
> version = 4.5.1

I hate python debug as it seems to be terrible at giving useful information so I will admit I can't tell you why it is complaining.

dtalens commented 2 years ago

Please, can you paste [[Defaults]] section?, thanks.

James-76 commented 2 years ago

Here you go from weewx.conf

    [[Defaults]]

        [[[Units]]]

            # The following section sets what unit to use for each unit group.
            # NB: The unit is always in the singular. I.e., 'mile_per_hour',
            # NOT 'miles_per_hour'
            [[[[Groups]]]]

                group_altitude = meter    # Options are 'foot' or 'meter'
                group_degree_day = degree_C_day    # Options are 'degree_F_day' or 'degree_C_day'
                group_distance = mile    # Options are 'mile' or 'km'
                group_pressure = mbar    # Options are 'inHg', 'mmHg', 'mbar', or 'hPa', or 'kPa'
                group_rain = mm    # Options are 'inch', 'cm', or 'mm'
                group_rainrate = mm_per_hour    # Options are 'inch_per_hour', 'cm_per_hour', or 'mm_per_hour'
                group_speed = knot    # Options are 'mile_per_hour', 'km_per_hour', 'knot', or 'meter_per_second'
                group_speed2 = knot2    # Options are 'mile_per_hour2', 'km_per_hour2', 'knot2', or 'meter_per_second2'
                group_temperature = degree_C    # Options are 'degree_F' or 'degree_C'

            # The following section sets the formatting for each type of unit
            [[[[StringFormats]]]]

                centibar = %.0f
                cm = %.2f
                cm_per_hour = %.2f
                degree_C = %.1f
                degree_F = %.1f
                degree_compass = %.0f
                foot = %.0f
                hPa = %.1f
                hour = %.1f
                inHg = %.3f
                inch = %.2f
                inch_per_hour = %.2f
                km = %.1f
                km_per_hour = %.0f
                km_per_hour2 = %.1f
                knot = %.0f
                knot2 = %.1f
                mbar = %.1f
                meter = %.0f
                meter_per_second = %.1f
                meter_per_second2 = %.1f
                mile = %.1f
                mile_per_hour = %.0f
                mile_per_hour2 = %.1f
                mm = %.1f
                mmHg = %.1f
                mm_per_hour = %.1f
                percent = %.0f
                second = %.0f
                uv_index = %.1f
                volt = %.1f
                watt_per_meter_squared = %.0f
                NONE = "   N/A"

            # The following section overrides the label used for each type of unit
            [[[[Labels]]]]

                meter = " meter", " meters"    # You may prefer "metre".
                day = " day", " days"
                hour = " hour", " hours"
                minute = " minute", " minutes"
                second = " second", " seconds"
                NONE = ""

            # The following section sets the format for each time scale.
            # The values below will work in every locale, but they may not look
            # particularly attractive.
            [[[[TimeFormats]]]]

                hour = %H:%M
                day = %X
                week = %X (%A)
                month = %x %X
                year = %x %X
                rainyear = %x %X
                current = %x %X
                ephem_day = %X
                ephem_year = %x %X

            [[[[Ordinates]]]]

                # Ordinal directions. The last one is for no wind direction
                directions = N, NNE, NE, ENE, E, ESE, SE, SSE, S, SSW, SW, WSW, W, WNW, NW, NNW, N/A

            # The following section sets the base temperatures used for the
            #  calculation of heating, cooling, and growing degree-days.
            [[[[DegreeDays]]]]

                # Base temperature for heating days, with unit:
                heating_base = 65, degree_F
                # Base temperature for cooling days, with unit:
                cooling_base = 65, degree_F
                # Base temperature for growing days, with unit:
                growing_base = 50, degree_F

            # A trend takes a difference across a time period. The following
            # section sets the time period, and how big an error is allowed to
            # still be counted as the start or end of a period.
            [[[[Trend]]]]

                time_delta = 10800    # 3 hours
                time_grace = 300    # 5 minutes

        # The labels to be used for each observation type
        [[[Labels]]]

            # Set to hemisphere abbreviations suitable for your location:
            hemispheres = N, S, E, W

            # Formats to be used for latitude whole degrees, longitude whole
            # degrees, and minutes:
            latlon_formats = %02d, %03d, %05.2f

            # Generic labels, keyed by an observation type.
            [[[[Generic]]]]
                barometer = Barometer
                dewpoint = Dew Point
                ET = ET
                heatindex = Heat Index
                inHumidity = Inside Humidity
                inTemp = Inside Temperature
                outHumidity = Humidity
                outTemp = Outside Temperature
                radiation = Radiation
                rain = Rain
                rainRate = Rain Rate
                UV = UV Index
                windDir = Wind Direction
                windGust = Gust Speed
                windGustDir = Gust Direction
                windSpeed = Wind Speed
                windchill = Wind Chill
                windgustvec = Gust Vector
                windvec = Wind Vector
                extraTemp1 = Temperature1
                extraTemp2 = Temperature2
                extraTemp3 = Temperature3

                # Sensor status indicators

                rxCheckPercent = Signal Quality
                txBatteryStatus = Transmitter Battery
                windBatteryStatus = Wind Battery
                rainBatteryStatus = Rain Battery
                outTempBatteryStatus = Outside Temperature Battery
                inTempBatteryStatus = Inside Temperature Battery
                consBatteryVoltage = Console Battery
                heatingVoltage = Heating Battery
                supplyVoltage = Supply Voltage
                referenceVoltage = Reference Voltage

        [[[Almanac]]]

            # The labels to be used for the phases of the moon:
            moon_phases = New, Waxing crescent, First quarter, Waxing gibbous, Full, Waning gibbous, Last quarter, Waning crescent
dtalens commented 2 years ago

Hi, thanks. The isue comes from graph.conf file because if I use default graph.conf.example it does not give an error. Add my graphs.conf.txt

James-76 commented 2 years ago

After slowly deleting sections, and using wee_reports to test it, it was started complaining when I added the following section back in under [homepage].

I then commented out the [[[lighting_strike_count]]] section and then it started working.

This means that there is something about how you have defined lightning_strike_count into your setup or something has changed with the weewx code with how it is being worked out.

     [[llamps]]
    title = "Número i distància dels llamps"
        subtitle = "Podeu consultar més gràfics de llamps al següent <strong><a href="/graphs/?graph=llamps" style="color:#e5554e">enllaç</a></strong>"
        #time_length = year
        #aggregate_type = max
        #aggregate_interval = 86400 # 1 day
        #gapsize = 86400000
        type = column
    yAxis_label = ""
        [[[lightning_strike_count]]]
           name = "Número de llamps"
           stacking = normal
        [[[lightning_distance]]]
           name = "Distància llamps (km)"
           stacking = normal
dtalens commented 2 years ago

Thanks @James-76, if I remove [[lightning_strike_count]] from my graph.conf file it will work again. Just deleting it from the [homepage] section still failed, I had to remove it from other sections so that it doesn't give an error. Now the question would be why does this happen?

James-76 commented 2 years ago

The error is saying that it is getting back '%' rather than an integer when looking up the StringFormats

Sounds like the obs_group is not possibly correctly defined for lighting_strike_count?

What have you defined in extensions.py for lighting_strike_count, and what happens when you search for that in belchertown/skin.conf?

eg here is my example for sunshineHours

# grep sunshine /home/weewx/bin/user/extensions.py
weewx.units.obs_group_dict['sunshineHours'] = 'group_radiation'

# grep group_radiation skin.conf
        group_radiation    = watt_per_meter_squared

root@pi:/home/weewx/skins/Belchertown# grep watt_per_meter_squared skin.conf
        group_radiation    = watt_per_meter_squared
        watt_per_meter_squared = %.0f
        watt_per_meter_squared = " W/m²"

As you can see watt_per_meter_squared is defined under [[StringFormats]] as the stringFormat for sunshineHours.

James-76 commented 2 years ago

gjr80 has commented on weewx-user which is similar to what you are seeing https://groups.google.com/g/weewx-user/c/VfpSRxNQits

"I see now there have been some changes have been introduced in WeeWX v4.6.x to how default labelling and formatting of observation types is determined and it appears that group_energy/watt_hour may have fallen through the cracks. I think we can work around the issue in your case by adding some additional lines to user/extensions.py:

weewx.units.default_unit_format_dict['watt_hour'] = '%.1f' weewx.units.default_unit_label_dict['watt_hour'] = u' Wh'

Again you will need to restart WeeWX for the changes to take effect and hopefully the first report cycle should add you missing units/formatting.

Gary"

dtalens commented 2 years ago

I added this code to the extension.py file but it still fails:

import weewx.units
weewx.units.obs_group_dict['lightning_strike_count'] = 'group_count'
weewx.units.default_unit_format_dict['lightning_strike_count'] = '%d'
weewx.units.default_unit_label_dict['lightning_strike_count'] = ""