Thanks Tom I didn't think of catching it in the expression doh!

I'll try and trap none as well with 
outTemp is None or outTemp < 10.0 or windGust is None or windGust > 100 

All I need now is some bad data lol

Mike

On Friday, July 17, 2020 at 2:41:18 PM UTC+1, Tom Keffer wrote:
>
> Instead of
>
> outTemp < 10.0 or windGust > 100
>
> try
>
> (outTemp is not None and outTemp < 10.0) or( windGust is not None and 
> windGust > 100)
>
> -tk
>
> On Fri, Jul 17, 2020 at 5:59 AM Mike Thompson <
> [email protected] <javascript:>> wrote:
>
>> Hi,
>>
>> To trap bad data I have a derivative of alarm.py that has been sucessully 
>> running for years on Python 2.7 and weewx 3.x.  I upgraded to weewx 4 and 
>> Python 3 a month or so ago and it has been running quite happily until a 
>> few days ago. 
>> The bad data parameters have been triggered and badData.py has been 
>> called. The line that causes the issue is;
>>  if eval(self.expression, None, record):
>> and the error is;
>>  TypeError: '<' not supported between instances of 'NoneType' and 'float'
>>
>> *FYI I'm a Python novice and copy from working code then tweek to what I 
>> need and iterate to a result!*
>>
>> I looked at Alarm.py in the examples directory and Customisation guide 
>> and the offending line is the same as in my badData.py. So I'm assuming 
>> that syntax is OK for Python3
>>
>> The error message is objecting to comparing a float to a None. I'm not 
>> sure why this is an issue now when it's run for several years.
>>
>> My bad data test is for a temp under 10 or wind gust over 100
>> In weewx.conf: 
>> badData_test = outTemp < 10.0 or windGust > 100
>> as it complaining about the < then it's the outTemp variable that's 
>> coming through as non numeric. 
>>
>> Lokking in the archive table around the time of the crash I can see a 
>> null record for outTemp and windGust
>> sqlite> select datetime, outtemp, windgust from archive where datetime > 
>> 1594530300 and datetime < 1594531800;
>> 1594530600|43.34|0.0
>> 1594530900||
>> 1594531319|43.52|0.0
>> 1594531619|43.52|0.0
>> I have had null values whilst running python2
>>
>> I'm not sure where to go from here, help!
>>
>>
>> *Configuration:*
>> Maplin/Fine Offset weather station been running since 2013
>> Raspberry PI 1B running Buster
>> Python 3.7.3
>>
>>
>> *1 . badData.py - attached*
>>
>> *2. extracts from Weewx.conf:*
>>
>>
>> ##############################################################################
>>
>> #   This section configures the internal weewx engine.
>>
>> [Engine]
>>
>>     [[Services]]
>>         # This section specifies the services that should be run. They are
>>         # grouped by type, and the order of services within each group
>>         # determines the order in which the services will be run.
>>         prep_services = weewx.engine.StdTimeSynch,
>>         data_services = ,
>>         process_services = weewx.engine.StdConvert, 
>> weewx.engine.StdCalibrate, weewx.engine.StdQC, 
>> weewx.wxservices.StdWXCalculate
>>         archive_services = weewx.engine.StdArchive, 
>> user.forecast.ZambrettiForecast, user.forecast.WUForecast, 
>> user.forecast.NWSFor$
>>         restful_services = weewx.restx.StdWunderground, 
>> weewx.restx.StdWOW, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.r$
>>         report_services = weewx.engine.StdPrint, weewx.engine.StdReport, 
>> user.alarm.MyAlarm, *user.badData.MyBadData*
>>
>> [Alarm]
>>     expression = " inHumidity > 90.0"
>>     time_wait = 86400
>>     smtp_host = xxxx
>>     smtp_user = xxxx
>>     smtp_password = xxxx
>>     mailto = xxxx
>>     from = xxxx
>>     subject = Humidity over 90!
>>    * badData_test = outTemp < 10.0 or windGust > 100*
>>     badData_subject = Weather Station spike detected
>>
>>
>>
>> *3. extrract from syslog at time of the crash*
>>
>> Jul 12 06:10:29 weepi weewx[513] INFO weewx.restx: WOW: Published record 
>> 2020-07-12 06:10:00 BST (1594530600)
>> Jul 12 06:10:29 weepi weewx[513] INFO weewx.restx: Wunderground-PWS: 
>> Published record 2020-07-12 06:10:00 BST (1594530600)
>> Jul 12 06:10:45 weepi weewx[513] INFO weewx.cheetahgenerator: Generated 8 
>> files for report SeasonsReport in 14.87 seconds
>> Jul 12 06:10:52 weepi weewx[513] INFO weewx.imagegenerator: Generated 15 
>> images for report SeasonsReport in 7.48 seconds
>> Jul 12 06:10:52 weepi weewx[513] INFO weewx.reportengine: Copied 0 files 
>> to /home/weewx/public_html
>> Jul 12 06:10:54 weepi weewx[513] INFO weewx.cheetahgenerator: Generated 6 
>> files for report SmartphoneReport in 0.84 seconds
>> Jul 12 06:10:56 weepi weewx[513] INFO weewx.imagegenerator: Generated 6 
>> images for report SmartphoneReport in 2.36 seconds
>> Jul 12 06:10:56 weepi weewx[513] INFO weewx.reportengine: Copied 0 files 
>> to /home/weewx/public_html/smartphone
>> Jul 12 06:10:57 weepi weewx[513] INFO weewx.cheetahgenerator: Generated 1 
>> files for report MobileReport in 0.38 seconds
>> Jul 12 06:10:59 weepi weewx[513] INFO weewx.imagegenerator: Generated 4 
>> images for report MobileReport in 1.66 seconds
>> Jul 12 06:10:59 weepi weewx[513] INFO weewx.reportengine: Copied 0 files 
>> to /home/weewx/public_html/mobile
>> Jul 12 06:11:03 weepi weewx[513] INFO weewx.cheetahgenerator: Generated 3 
>> files for report exfoliation in 3.55 seconds
>> Jul 12 06:11:10 weepi weewx[513] INFO weewx.imagegenerator: Generated 15 
>> images for report exfoliation in 6.91 seconds
>> Jul 12 06:11:10 weepi weewx[513] INFO weewx.reportengine: Copied 0 files 
>> to /home/weewx/public_html/exfoliation
>> Jul 12 06:15:31 weepi weewx[513] INFO weewx.manager: Added record 
>> 2020-07-12 06:15:00 BST (1594530900) to database 'weewx.sdb'
>> Jul 12 06:15:31 weepi weewx[513] INFO weewx.manager: Added record 
>> 2020-07-12 06:15:00 BST (1594530900) to daily summary in 'weewx.sdb'
>> Jul 12 06:15:31 weepi /weewxd: forecast: MainThread: Zambretti: starting 
>> thread
>> Jul 12 06:15:31 weepi /weewxd: forecast: MainThread: UKMO: starting thread
>> Jul 12 06:15:31 weepi weewx[513] INFO weewx.engine: Main loop exiting. 
>> Shutting engine down.
>> Jul 12 06:15:31 weepi weewx[513] INFO weewx.engine: Shutting down 
>> StdReport thread
>> Jul 12 06:15:31 weepi weewx[513] INFO weewx.restx: WOW: Published record 
>> 2020-07-12 06:15:00 BST (1594530900)
>> Jul 12 06:15:31 weepi weewx[513] INFO weewx.restx: Wunderground-PWS: 
>> Published record 2020-07-12 06:15:00 BST (1594530900)
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__: Caught unrecoverable 
>> exception:
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****  '<' not 
>> supported between instances of 'NoneType' and 'float'
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****  Traceback 
>> (most recent call last):
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 195, in run
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****      
>> self.dispatchEvent(weewx.Event(weewx.CHECK_LOOP, packet=packet))
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 224, in dispatchEvent
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****      
>> callback(event)
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 578, in check_loop
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****      raise 
>> BreakLoop
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****  
>> weewx.engine.BreakLoop
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****  
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****  During 
>> handling of the above exception, another exception occurred:
>> Jul 12 06:15:31 weepi weewx[513] CRITICAL __main__:     ****  
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****  Traceback 
>> (most recent call last):
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewxd", line 154, in main
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      
>> engine.run()
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 202, in run
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      
>> self.dispatchEvent(weewx.Event(weewx.POST_LOOP))
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 224, in dispatchEvent
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      
>> callback(event)
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 588, in post_loop
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      
>> self._software_catchup()
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 658, in _software_catchup
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      
>> origin='software'))
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/weewx/engine.py", line 224, in dispatchEvent
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      
>> callback(event)
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "/home/weewx/bin/user/badData.py", line 94, in newArchiveRecord
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****      if 
>> eval(self.expression, None, record):                       # NOTE 2
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****    File 
>> "<string>", line 1, in <module>
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****  TypeError: 
>> '<' not supported between instances of 'NoneType' and 'float'
>> Jul 12 06:15:32 weepi weewx[513] CRITICAL __main__:     ****  Exiting.
>> Jul 12 06:17:01 weepi CRON[32233]: (root) CMD (   cd / && run-parts 
>> --report /etc/cron.hourly)
>> Jul 12 06:17:33 weepi systemd[1]: Starting Daily apt upgrade and clean 
>> activities...
>> Jul 12 06:17:40 weepi systemd[1]: apt-daily-upgrade.service: Succeeded.
>>
>> Thanks in Advance
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/d77920b8-55ec-487b-9d21-579edf931e74o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/d77920b8-55ec-487b-9d21-579edf931e74o%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/0e804870-81c6-43cd-8a10-251117dfa412o%40googlegroups.com.

Reply via email to