BobAtchley / weewx-ws6in1

weewx driver for the 6 in 1 PC weather station clones
GNU General Public License v3.0
5 stars 6 forks source link

unsupported operand type(s) for -: 'int' and 'NoneType' #8

Closed PeterHurn closed 3 years ago

PeterHurn commented 3 years ago

Hi All,

So the driver seems to load but I am seeing the following Critical error, any ideas?

Nov 7 18:00:30 raspberrypi weewx[615] INFO weewx.engine: Using binding 'wx_binding' to database 'weewx.sdb' Nov 7 18:00:30 raspberrypi weewx[615] INFO weewx.manager: Starting backfill of daily summaries Nov 7 18:00:30 raspberrypi weewx[615] INFO user.ws6in1: find_my_device::success getting dev Nov 7 18:00:30 raspberrypi kernel: [ 866.527875] usb 1-1.2.1: reset full-speed USB device number 6 using dwc_otg Nov 7 18:00:31 raspberrypi weewx[615] INFO user.ws6in1: initialise_my_device::success getting configuration Nov 7 18:00:31 raspberrypi weewx[615] INFO user.ws6in1: initialise_my_device::my_cfg.bConfigurationValue = 1 Nov 7 18:00:31 raspberrypi weewx[615] INFO user.ws6in1: initialise_my_device::my_cfg.bNumInterfaces = 1 Nov 7 18:00:32 raspberrypi weewx[615] INFO weewx.engine: Main loop exiting. Shutting engine down. Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: Caught unrecoverable exception: Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: unsupported operand type(s) for -: 'int' and 'NoneType' Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: Traceback (most recent call last): Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/weewxd", line 154, in main Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: engine.run() Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 173, in run Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: self.dispatchEvent(weewx.Event(weewx.STARTUP)) Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 241, in dispatchEvent Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: callback(event) Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 580, in startup Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: self._catchup(self.engine.console.genStartupRecords) Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 690, in _catchup Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: for record in generator(lastgood_ts): Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/user/ws6in1.py", line 1231, in genStartupRecords Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: packet = self.decode(level) Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: File "/usr/share/weewx/user/ws6in1.py", line 729, in decode Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: my_interval = my_time - self.last_ts Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: TypeError: unsupported operand type(s) for -: 'int' and 'NoneType' Nov 7 18:00:32 raspberrypi weewx[615] CRITICAL main: Exiting.

BobAtchley commented 3 years ago

Not sure how this has not been found before. Weewx calls genStartupRecords to read stored console data values with a time parameter - WS6in1 driver had made the bad assumption that their would always be a value provided, but in fact if the database is empty weewx cannot get a previous time so sets this field to None. The change is simple, but tricky to test (my weewx database is not empty!), I'll provide a new version shortly. Please let me know whether this works

PeterHurn commented 3 years ago

Thanks Bob, apologies for posting here and in the Google Weewx group just wasn't sure if it was an issue with Weewx or the driver. I'll test it now and feedback, thank you for the quick reply.

PeterHurn commented 3 years ago

Hi Bob,

Wiped the SD card in the Raspberry Pi and reinstalled everything from clean.

Unfortunately, I am still getting the following:

Nov 8 16:19:44 raspberrypi weewx[2268] INFO main: Starting up weewx version 4.2.0 Nov 8 16:19:44 raspberrypi weewx[2268] INFO weewx.engine: Using binding 'wx_binding' to database 'weewx.sdb' Nov 8 16:19:44 raspberrypi weewx[2268] INFO weewx.manager: Starting backfill of daily summaries Nov 8 16:19:44 raspberrypi weewx[2268] INFO user.ws6in1: find_my_device::success getting dev Nov 8 16:19:44 raspberrypi kernel: [ 2139.717886] usb 1-1.2.1: reset full-speed USB device number 6 using dwc_otg Nov 8 16:19:44 raspberrypi weewx[2268] INFO user.ws6in1: initialise_my_device::success getting configuration Nov 8 16:19:44 raspberrypi weewx[2268] INFO user.ws6in1: initialise_my_device::my_cfg.bConfigurationValue = 1 Nov 8 16:19:44 raspberrypi weewx[2268] INFO user.ws6in1: initialise_my_device::my_cfg.bNumInterfaces = 1 Nov 8 16:19:45 raspberrypi weewx[2268] INFO weewx.engine: Main loop exiting. Shutting engine down. Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: Caught unrecoverable exception: Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: '>' not supported between instances of 'int' and 'NoneType' Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: Traceback (most recent call last): Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: File "/usr/share/weewx/weewxd", line 154, in main Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: engine.run() Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 173, in run Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: self.dispatchEvent(weewx.Event(weewx.STARTUP)) Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 241, in dispatchEvent Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: callback(event) Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 580, in startup Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: self._catchup(self.engine.console.genStartupRecords) Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: File "/usr/share/weewx/weewx/engine.py", line 690, in _catchup Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: for record in generator(lastgood_ts): Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: File "/usr/share/weewx/user/ws6in1.py", line 1261, in genStartupRecords Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: if packet['dateTime'] > since_ts: Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: TypeError: '>' not supported between instances of 'int' and 'NoneType' Nov 8 16:19:45 raspberrypi weewx[2268] CRITICAL main: Exiting.

BobAtchley commented 3 years ago

Having carefully checked and double checked self.last_ts could be null, I didn't check if since_ts was used and assumed not null. Apologies, I did say it was difficult to test. 1.01 will be updated shortly

PeterHurn commented 3 years ago

Thanks Bob, just ran csv_ws6in1 if it helps:

pi@raspberrypi:/usr/share/weewx/user $ sudo python3 ./csv_ws6in1 CSV output file: ws6in1_2020-11-08-16-46-46.csv Raw output file: ws6in1_2020-11-08-16-46-46.raw gen_startup_records: starting archive loop ... find_my_device::success getting dev initialise_my_device::dev.bLength = 18 initialise_my_device::dev.bNumConfigurations = 1 initialise_my_device::dev.bDeviceClass = 0 initialise_my_device::success getting configuration initialise_my_device::myCfg.bConfigurationValue = 1 initialise_my_device::myCfg.bNumInterfaces = 1 initialise_my_device::Set idle done: 0 Initialisation successful WARNING: gen_startup_records: bad CRC WARNING: gen_startup_records: bad CRC Finished

PeterHurn commented 3 years ago

date, time, dateTime, inTemp, inHumidity, outTemp, outHumidity, rainDay, rainRate, rain, windSpeed, windGust, windDir, pressure, barometer, UV, dewpoint, h$ 2018-01-13, 00:30, 1515803400, 24.9, 39, None, None, 0.0, 0.0, 0.0, None, None, None, 1016, 1013, None, None, None, 95, None, None, None, None, None, None,$ 2016-12-31, 01:00, 1483146000, 24.8, 42, None, None, 0.0, 0.0, 0.0, None, None, None, 1016, 1013, None, None, None, 10, None, None, None, None, None, None,$ 2016-12-31, 01:30, 1483147800, 24.3, 43, None, None, 0.0, 0.0, 0.0, None, None, None, 1017, 1014, None, None, None, 10, None, None, None, None, None, None,$ 2020-10-30, 19:00, 1604084400, 20.3, 64, None, None, 0.0, 0.0, 0.0, None, None, None, 1010, 1013, None, None, None, None, None, None, None, None, None, Non$

...

BobAtchley commented 3 years ago

Just a warning ... the first 3 records above have rubbish times (i.e. from when you powered up the weather station before you corrected the time). The ws6in1 driver will set the time on the console, so if you haven't I would advise using ntp on your raspberry pi.

PeterHurn commented 3 years ago

Just a warning ... the first 3 records above have rubbish times (i.e. from when you powered up the weather station before you corrected the time). The ws6in1 driver will set the time on the console, so if you haven't I would advise using ntp on your raspberry pi.

Thanks Bob, will do, appreciate all your help with this :)

PeterHurn commented 3 years ago

Thanks Bob, all working.