Found a solution to the problem, everything is back to normal now.

Added these lines to the end of  *lowest_temperature.py*:

# Tell the unit system what group our new observation type, 
'lowTemperature', belongs to:
weewx.units.obs_group_dict['lowTemperature'] = "group_temperature" 

Somehow this wasn't required in 4.1.1. Maybe more people will run into this 
issue when upgrading to 4.3.0.

Op woensdag 6 januari 2021 om 19:51:20 UTC+1 schreef Arend:

> The get_scalar function is still returning the correct values:
> [image: Current conditions.png]
> I have put Outside Temperature, Temperature1 and the calculated Lowest 
> Temperature in one chart. I really don't understand why the get_series 
> calculation is now outputting such high values. Any suggestions are welcome.
>
> [image: daytempdew (1).png]
>
> Op woensdag 6 januari 2021 om 19:24:22 UTC+1 schreef tke...@gmail.com:
>
>> I would guess that the problem is that you are always returning 
>> lowestTemperature in Fahrenheit, but your data records are in Celsius.
>>
>> That part of XTypes has not changed. I don't know why it worked before. 
>> Perhaps units were in Fahrenheit before?
>>
>> -tk
>>
>> On Wed, Jan 6, 2021 at 10:16 AM Arend <arendh...@gmail.com> wrote:
>>
>>> Hello Tom,
>>>
>>> I get strange output as can be seen in the chart below. It apperas the 
>>> series isn't calculated/retrieved as it did before the upgrade. I hope this 
>>> helps to understand.
>>>
>>> [image: daytempdew.png]
>>>
>>> Regards, Arend
>>> Op woensdag 6 januari 2021 om 19:12:47 UTC+1 schreef tke...@gmail.com:
>>>
>>>> It would help if we knew what the problem was. "No longer works" 
>>>> doesn't tell us much.
>>>>
>>>> On Wed, Jan 6, 2021 at 10:00 AM Arend <arendh...@gmail.com> wrote:
>>>>
>>>>> In addition to the previous: the get_scalar function still seems to be 
>>>>> working but the get_series function no longer works.
>>>>>
>>>>> Op woensdag 6 januari 2021 om 18:33:12 UTC+1 schreef Arend:
>>>>>
>>>>>> Everything worked fine until I did the upgrade.
>>>>>>
>>>>>> I guess something has changed in the way XTypes are handled?
>>>>>>
>>>>>> *This is the code I use in extensions.py:*
>>>>>>
>>>>>> #
>>>>>> #    Copyright (c) 2009-2015 Tom Keffer <tke...@gmail.com>
>>>>>> #
>>>>>> #    See the file LICENSE.txt for your full rights.
>>>>>> #
>>>>>>
>>>>>> """User extensions module
>>>>>>
>>>>>> This module is imported from the main executable, so anything put 
>>>>>> here will be
>>>>>> executed before anything else happens. This makes it a good place to 
>>>>>> put user
>>>>>> extensions.
>>>>>> """
>>>>>>
>>>>>> import locale
>>>>>> # This will use the locale specified by the environment variable 
>>>>>> 'LANG'
>>>>>> # Other options are possible. See:
>>>>>> # http://docs.python.org/2/library/locale.html#locale.setlocale
>>>>>> locale.setlocale(locale.LC_ALL, '')
>>>>>>
>>>>>> import user.lowest_temperature
>>>>>> import weewx.xtypes
>>>>>>
>>>>>>
>>>>>> weewx.xtypes.xtypes.append(user.lowest_temperature.LowestTemperature())
>>>>>>
>>>>>>
>>>>>> *This is the code in lowest_temperature.py:*
>>>>>>
>>>>>> import weewx.units
>>>>>> import weewx.xtypes
>>>>>> from weewx.units import ValueTuple
>>>>>>
>>>>>> class LowestTemperature(weewx.xtypes.XType):
>>>>>>
>>>>>>   def get_scalar(self, obs_type, record, dbmanager):
>>>>>>     """Determine which sensor has lowest temperature."""
>>>>>>     if obs_type != 'lowTemperature':
>>>>>>       raise weewx.UnknownType
>>>>>>     try:
>>>>>>       record_us = weewx.units.to_US(record)
>>>>>>       if record_us['outTemp'] == None or record_us['extraTemp1'] == 
>>>>>> None:
>>>>>>       # if record_us['outTemp'] < 100 or record_us['extraTemp1'] < 
>>>>>> 100:
>>>>>>         raise TypeError("Temperature(s) equal to None")
>>>>>>       if record_us['outTemp'] <= record_us['extraTemp1']:
>>>>>>         lowTemperature = record_us['outTemp']
>>>>>>       else:
>>>>>>         lowTemperature = record_us['extraTemp1']
>>>>>>       return ValueTuple(lowTemperature, "degree_F", 
>>>>>> "group_temperature")
>>>>>>     except KeyError:
>>>>>>       # Don't have everything we need. Raise an exception.
>>>>>>       raise weewx.CannotCalculate(obs_type)
>>>>>>   
>>>>>>   def get_series(self, obs_type, timespan, db_manager, 
>>>>>> aggregate_type=None, aggregate_interval=None):
>>>>>>     if obs_type != 'lowTemperature':
>>>>>>       raise weewx.UnknownType
>>>>>>     start_vec = list()
>>>>>>     stop_vec = list()
>>>>>>     data_vec = list()
>>>>>>     if aggregate_type:
>>>>>>       raise weewx.UnknownAggregation(aggregate_type)
>>>>>>     for record in db_manager.genSql("SELECT `dateTime`, `interval`, 
>>>>>> `usUnits`, `outTemp`, `extraTemp1` FROM `archive` WHERE `dateTime` > 
>>>>>> %(start)s AND `dateTime` <= %(stop)s;" % {'start': timespan[0], 'stop': 
>>>>>> timespan[1]}):
>>>>>>       if (record[2] != 1):
>>>>>>         raise weewx.CannotCalculate("units are not US")
>>>>>>       if record[3] == None or record[4] == None:
>>>>>>       # if record[3] < 100 or record[4] < 100:
>>>>>>         raise TypeError("Temperature(s) equal to None") 
>>>>>>       start_vec.append(record[0] - record[1] * 60)
>>>>>>       stop_vec.append(record[0])
>>>>>>       if record[3] <= record[4]:
>>>>>>         data_vec.append(record[3])
>>>>>>       else:
>>>>>>         data_vec.append(record[4])
>>>>>>     return (ValueTuple(start_vec, 'unix_epoch', 'group_time'), 
>>>>>> ValueTuple(stop_vec, 'unix_epoch', 'group_time'), ValueTuple(data_vec, 
>>>>>> "degree_F", "group_temperature"))
>>>>>>
>>>>>> Do I need to rewrite all code?
>>>>>>
>>>>>> -- 
>>>>> 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/5ac947ed-240d-428b-8a69-c0186359d97cn%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/weewx-user/5ac947ed-240d-428b-8a69-c0186359d97cn%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+...@googlegroups.com.
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/weewx-user/1b588685-d1ba-4940-99d7-b830a6b0b700n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/weewx-user/1b588685-d1ba-4940-99d7-b830a6b0b700n%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/b0cab555-967c-4c1c-8899-e01fc6222562n%40googlegroups.com.

Reply via email to