Is it just a matter of checking for None first i.e.

 badData_test = outTemp is None or outTemp < 10.0 or windGust is None or 
windGust > 100 or *rain is None or rain* > 10 or *rainRate is None* or 
rainRate > 100


On Saturday, August 31, 2024 at 4:23:59 PM UTC+1 
[email protected] wrote:

> Weewx version 4.10 running on RPI 4 using FO weather station. 
> Last change was 2 weeks ago when weather station reported crazy rain 
> volume and rain rate. I amended the alarm condition from;
> badData_test = outTemp is None or outTemp < 10.0 or windGust is None or 
> windGust > 100
>
> to
>  badData_test = outTemp is None or outTemp < 10.0 or windGust is None or 
> windGust > 100 *or rain > 10 or rainRate > 100*
>
> Weewx last ran successfully at 00:55 30 August and aborted with the 
> following 
>
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__: Caught unrecoverable 
> exception:
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****  '>' not 
> supported between instances of 'NoneType' and 'int'
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****  Traceback 
> (most recent call last):
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 214, in run
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  self.dispatchEvent(weewx.Event(weewx.CHECK_LOOP, packet=packet))
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 245, in dispatchEvent
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  callback(event)
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 634, in check_loop
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****      raise 
> BreakLoop
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     **** 
>  weewx.engine.BreakLoop
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****  During 
> handling of the above exception, another exception occurred:
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****  Traceback 
> (most recent call last):
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewxd", line 154, in main
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  engine.run()
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 221, in run
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  self.dispatchEvent(weewx.Event(weewx.POST_LOOP))
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 245, in dispatchEvent
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  callback(event)
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 644, in post_loop
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  self._software_catchup()
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 717, in _software_catchup
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  origin='software'))
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/weewx/engine.py", line 245, in dispatchEvent
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****     
>  callback(event)
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "/home/weewx/bin/user/badData.py", line 94, in newArchiveRecord
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****      if 
> eval(self.expression, None, record):                       # NOTE 2
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****    File 
> "<string>", line 1, in <module>
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****  TypeError: 
> '>' not supported between instances of 'NoneType' and 'int'
> Aug 30 01:05:16 weepi weewx[6744] CRITICAL __main__:     ****  Exiting.
>
> I've checked the database and sure enough there are 5 entries from 01:05 
> to 03:07 in the archive table where rain is NULL. I was not expecting rain 
> to ever be NULL. Checking the database there are 909 occurrences over the 
> last 10 years where rain is NULL. Also looking at other columns such as 
> outtemp there are NULL occurrences as well.
> Also I'm not sure about TypeError: '>' not supported between instances of 
> 'NoneType' and 'int'. Which seems to imply that the > character is the 
> issue. However if condition statement is incorrect I would expect it to 
> fail every time it runs.   
>
> snippet from badData.py (I copied the alarm example many years back)
>
>     def newArchiveRecord(self, event):
>         """Gets called on a new archive record event."""
>
>         # Get the new archive record:
>         record = event.record
>         # Evaluate the expression in the context of the event archive 
> record.
>         # Sound the alarm if it evaluates true:
>        * if eval(self.expression, None, record):  *                     # 
> NOTE 2
>             # Sound the alarm!
>             # Launch in a separate thread so it doesn't block the main 
> LOOP thread:
>             t  = threading.Thread(target = MyBadData.soundTheAlarm, 
> args=(self, record))
>             t.start()
>             # Record when the message went out:
>             self.last_msg_ts = time.time()
>
>
>
>
> Reverting the alarm condition to remove rain check, WEEWX successfully ran 
> as you'd expect.
> I then put the rain alarm condition back in and weewx ran successfully 
> again as expected.
>
> My Python skills are pretty basic hence my query is how can I trap this 
> NULL condition?
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/288441e2-057d-442e-8bad-891549925b49n%40googlegroups.com.

Reply via email to