New Vantage Pro ISS installation has clobbered weewx.

81 views
Skip to first unread message

Peter Fletcher

unread,
Aug 10, 2020, 7:33:10 PM8/10/20
to weewx-user
I know that this sounds insane, but my modified (to add some extra data derived from external sensors) weewx installation which has been running for a couple of months now crashes on startup. I stopped weewx to replace a (very) old Vantage Pro 2 ISS, removed the old unit, put the new unit in its place, reconfigured the console to communicate with the new unit, observed that the console was showing valid data, and restarted weewx, which is running on a Pi connected to the console via a MeteoPi. weewx immediately crashes, with the following exception tree, arising from my user code.
Traceback (most recent call last):
  File "/usr/share/weewx/weewxd", line 261, in <module>
    main()
  File "/usr/share/weewx/weewxd", line 154, in main
    engine.run()
  File "/usr/share/weewx/weewx/engine.py", line 158, in run
    self.dispatchEvent(weewx.Event(weewx.STARTUP))
  File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
    callback(event)
  File "/usr/share/weewx/weewx/engine.py", line 530, in startup
    self._catchup(self.engine.console.genStartupRecords)
  File "/usr/share/weewx/weewx/engine.py", line 643, in _catchup
    origin='hardware'))
  File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
    callback(event)
  File "/usr/share/weewx/user/NewTH.py", line 19, in read_file
    event.record['extraTemp1'] = event.record['inTemp']
KeyError: 'inTemp'

It looks as if the event record no longer contains an 'inTemp' item, but why not??!! Again, this installation has been running for months, through multiple apt update/upgrades and reboots. The only thing that changed was the Vantage ISS - I'm using the same console that I always did. Does this make sense to anyone? I will try reverting to a standard weewx config, but even if this works, it doesn't really help - I want to use and save the extra data!

The contents of the user code source file are
import syslog
import weewx
import time
import os

from weewx.wxengine import StdService

class ArchTHService(StdService):
   
def __init__(self, engine, config_dict):
       
super(ArchTHService, self).__init__(engine, config_dict)
        d
= config_dict.get('ArchTHService', {})
       
self.filename = d.get('filename', '/var/tmp/THNow.txt')
       
self.filename2 = d.get('filename', '/var/tmp/THBNow.txt')
        syslog
.syslog(syslog.LOG_INFO, "ArchTH: using %s" % self.filename)
       
self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)

   
def read_file(self, event):
# save the console values in 'extra' slots
       
event.record['extraTemp1'] = event.record['inTemp'] ## This is where it fails
       
event.record['extraHumid1'] = event.record['inHumidity']
       
try:
           
#skip it if it's stale. Console values will be used instead
           
if time.time() - os.path.getmtime("/var/tmp/THNow.txt") < 600: #10 minutes
               
with open(self.filename) as f:
                    line
= f.read() # contains temp & humidity, comma-separated
                values
=line.split(',')
                syslog
.syslog(syslog.LOG_DEBUG, "ArchTH: found value of %s" % line)
               
event.record['inTemp'] = float(values[0])
               
event.record['inHumidity'] = float(values[1])
               
with open(self.filename2) as f:
                    line
= f.read() # contains basement temp & humidity, comma-separated
                values
=line.split(',')
                syslog
.syslog(syslog.LOG_DEBUG, "ArchTH(B): found value of %s" % line)
               
event.record['extraTemp2'] = float(values[0])
               
event.record['extraHumid2'] = float(values[1])

       
except Exception as e:
            syslog
.syslog(syslog.LOG_ERR, "ArchTH: cannot interpret value: %s" % e)

class LoopTHService(StdService):
    loopcount
= 0
    lastT
= 0
    lastH
=0

   
def __init__(self, engine, config_dict):
       
super(LoopTHService, self).__init__(engine, config_dict)
        d
= config_dict.get('LoopTHService', {})
       
self.filename = d.get('filename', '/var/tmp/THNow.txt')
        syslog
.syslog(syslog.LOG_INFO, "LoopTH: using %s" % self.filename)
       
self.bind(weewx.NEW_LOOP_PACKET, self.read_file)

   
def read_file(self, event):
       
if self.loopcount == 0:
           
try:
               
#skip it if it's stale. Vantage Console values will be used instead
               
if time.time() - os.path.getmtime("/var/tmp/THNow.txt") < 300: #5 minutes
                   
with open(self.filename) as f:
                        line
= f.read() # contains temp & humidity, comma-separated
                    values
=line.split(',')
                    syslog
.syslog(syslog.LOG_DEBUG, "LoopTH: found value of %s" % line)
                   
event.packet['inTemp'] = float(values[0])
                   
event.packet['inHumidity'] = float(values[1])
                   
self.lastT=float(values[0])
                   
self.lastH=float(values[1])
                   
self.loopcount += 1
           
except Exception as e:
                syslog
.syslog(syslog.LOG_ERR, "LoopTH: cannot interpret value: %s" % e)  
       
else:
           
self.loopcount += 1
           
if self.loopcount >= 30:
               
self.loopcount = 0
           
event.packet['inTemp'] = self.lastT
           
event.packet['inHumidity'] = self.lastH
 


Tom Keffer

unread,
Aug 10, 2020, 8:23:12 PM8/10/20
to weewx-user
I'm not familiar with the Meteo-Pi, but one thing I notice is that the crash is happening during the initial "catch up" phase. This phase happens before the main loop is entered, and allows weewx (and the database) to "catch up" with any data stored on the logger.

So, my guess would be that the Meteo-Pi is not storing, or emitting, inside temperature.

Try running weewxd directly from the command line. It will print out the archive records it is getting off the logger. See what's in them.

-tk


--
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/740ef422-1bc3-45a3-87e4-e5766d2ed213o%40googlegroups.com.

Peter Fletcher

unread,
Aug 10, 2020, 8:48:16 PM8/10/20
to weewx-user
Now I know I'm insane!

I copied my old conf file, modified the original to disable the user code, and confirmed that it worked with weewxd. However, weewx with the vanilla conf still crashed as a service. I then stopped the service and started it again and it worked! Stopped the service, copied back the original conf file, restarted it and it worked without problems!! Go figure!

On Monday, August 10, 2020 at 7:33:10 PM UTC-4, Peter Fletcher wrote:
I know that this sounds insane, but my modified (to add some extra data derived from external sensors) weewx installation which has been running for a couple of months now crashes on startup. I stopped weewx to replace a (very) old Vantage Pro 2 ISS, removed the old unit, put the new unit in its place, reconfigured the console to communicate with the new unit, observed that the console was showing valid data, and restarted weewx, which is running on a Pi connected to the console via a MeteoPi. weewx immediately crashes, with the following exception tree, arising from my user code.
....

Tom Keffer

unread,
Aug 10, 2020, 8:57:51 PM8/10/20
to weewx-user
It may be past the "catch up" phase. 

This would be a lot easier to diagnose with the log...

--
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.

Peter Fletcher

unread,
Aug 12, 2020, 9:53:19 AM8/12/20
to weewx-user
Everything is still working normally. For the record, however, I have attached the complete log listing for one of the crashes when it wasn't. At least to me, it gives no more information than the text printed to stderror.
weewxError.txt
Reply all
Reply to author
Forward
0 new messages