gjr80 / weewx-realtime_gauge-data

Near realtime support for updating of SteelSeries Weather Gauges by WeeWX
GNU General Public License v3.0
9 stars 5 forks source link

TypeError: '<=' not supported between instances of 'float' and 'str' #29

Closed hoetzgit closed 1 year ago

hoetzgit commented 1 year ago

I installed your extension today for the first time and tested it a bit. Thereby I noticed this error:

Nov  4 12:20:59 weewx weewx[3083708] CRITICAL user.rtgd: Unexpected exception of type <class 'TypeError'>
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: **** Traceback (most recent call last):
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****   File "/home/weewx/bin/user/rtgd.py", line 1831, in run
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****     self.process_packet(_package['payload'])
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****   File "/home/weewx/bin/user/rtgd.py", line 1886, in process_packet
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****     cached_packet = self.packet_cache.get_packet(_conv_packet['dateTime'],
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****   File "/home/weewx/bin/user/rtgd.py", line 3019, in get_packet
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****     packet[obs] = self.get_value(obs, ts, max_age)
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****   File "/home/weewx/bin/user/rtgd.py", line 3005, in get_value
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: ****     if obs in self.cache and ts - self.cache[obs]['ts'] <= max_age:
Nov  4 12:20:59 weewx weewx[3083708] DEBUG user.rtgd: rtgdthread: **** TypeError: '<=' not supported between instances of 'float' and 'str'
Nov  4 12:20:59 weewx weewx[3083708] CRITICAL user.rtgd: Thread exiting. Reason: '<=' not supported between instances of 'float' and 'str'

i have temporarily corrected it that way:

if obs in self.cache and ts - self.cache[obs]['ts'] <= float(max_age):

I do not know if this is correct, but then the error no longer occurred.

Henry

Edit: If you need more information, here are all the configurations: GitHub

hoetzgit commented 1 year ago

Thank you very much for your adjustments. The error no longer occurs.

Henry

gjr80 commented 1 year ago

Thanks for picking up that error. As you have discovered I have fixed this a little closer to the source of the error.

I had a couple of other issues I wanted to check before releasing v0.6.1. As it turns out these issues required no code changes, the v0.6.1 package just published has identical code to that which you downloaded except for a few changed comment lines. So it is not necessary for you to install from the recently released v0.6.1 package.