I just found out that I had the same problem when upgrading my weewx 3.9.2 to the latest 4.5.1. socketlogger is giving the same error as the original reporter.
I used the 2to3 tool of python to translate the socketlogger.py. Here the version for python 3. ----------------- # # Copyright (c) 2012 Tom Keffer <[email protected]> # # See the file LICENSE.txt for your full rights. # # $Revision: 1 $ # $Author: pobrien $ # $Date: 2016-01-14 08:00:00 -0500 (Thu, 14 Jan 2016) $ # """ This driver connects to a socket (typically on localhost) and waits for packet data. Once a new line comes into the socket, this will process the data and submit the packet back to weewx. Based on the hackulink driver, which was based on the weewx wmr100 driver """ import socket import syslog import time import weedb import weewx.drivers import weeutil.weeutil import weewx.wxformulas def logmsg(dst, msg): syslog.syslog(dst, 'SocketLogger: %s' % msg) def loginf(msg): logmsg(syslog.LOG_INFO, msg) def logerror(msg): logmsg(syslog.LOG_ERROR, msg) def logdebug(msg): logmsg(syslog.LOG_DEBUG, msg) def loader(config_dict, engine): station = SocketLogger(**config_dict['SocketLogger']) return station class SocketLogger(weewx.drivers.AbstractDevice): """ Driver for the SocketLogger station. """ def __init__(self, **stn_dict) : """ Initialize an object of type SocketLogger. """ self.host_ip = stn_dict.get('host_ip') self.host_port = int(stn_dict.get('host_port')) self.timeout = float(stn_dict.get('timeout')) self.station_hardware = stn_dict.get('hardware') self.lastrain = None self.port = None self.openPort() def hardware_name(self): return self.station_hardware def openPort(self): try: loginf("Connecting to socket on %s port %s" % (self.host_ip, self.host_port) ) self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket.settimeout(self.timeout) self.socket.connect( (self.host_ip, self.host_port) ) except (socket.error, socket.timeout, socket.herror) as ex: logerror("Socket error while opening port %d to ethernet host %s." % (self.host_port, self.host_ip)) # Reraise as a weewx I/O error: raise weewx.WeeWxIOError(ex) except: logerror("Unable to connect to host %s on port %d." % (self.host_ip, self.host_port)) raise logdebug("Connected to host %s on port %d" % (self.host_ip, self.host_port)) self.port = self.socket.makefile() def closePort(self): self.port.close() def check_rain(self, daily_rain_counter): # *** DO NOT use the &rainin= data! *** # Handle the rain accum by taking the &dailyrainin= reading ONLY. # Then submit those minor increments of daily rain to weewx. rain = 0.0 current_rain = float(daily_rain_counter) if self.lastrain is not None: if (current_rain >= self.lastrain): rain = float(current_rain) - float(self.lastrain) #loginf("Checking for new rain accumulation") #loginf(rain) self.lastrain = current_rain return rain #=============================================================================== # LOOP record decoding functions #=============================================================================== def genLoopPackets(self): """ Generator function that continuously returns loop packets """ for _packet in self.genPackets(): yield _packet def genPackets(self): """ Generate measurement packets from the socket. """ while True: try: _line = self.port.readline(4096) #loginf(_line) except (socket.timeout, socket.error) as ex: raise weewx.WeeWxIOError(ex) if _line == None: break if _line[0:8] == 'outTemp=': #loginf("New line on socket, processing weather data.") yield self._process_message(_line) else: #loginf("New line on socket, but did not start with 'outTemp='. Ignoring line.") pass def _process_message(self, message): _packet = {} # Separate line into a dict message = message.rstrip() # Strip any newline line = message.split(',') # Split by comma data = dict( [ i.split( '=' ) for i in line] ) # Create dictionary of the values _packet['dateTime'] = int(time.time()) _packet['usUnits'] = weewx.US _packet['outTemp'] = float( data["outTemp"] ) _packet['outHumidity'] = float( data["outHumidity"] ) _packet['inTemp'] = float( data["inTemp"] ) _packet['inHumidity'] = float( data["inHumidity"] ) _packet['barometer'] = float( data["barometer"] ) _packet['rain'] = self.check_rain( data["dailyrain"] ) _packet['windDir'] = float( data["windDir"] ) _packet['windSpeed'] = float( data["windSpeed"] ) _packet['windGust'] = float( data["windGust"] ) _packet['windGustDir'] = float( data["windDir"] ) _packet['radiation'] = float( data["radiation"] ) _packet['UV'] = float( data["UV"] ) _packet['txBatteryStatus'] = float( data["txBatteryStatus"] ) #loginf(_packet) return _packet --------------------------- i now get: Nov 21 14:11:30 pi4 systemd[1]: Starting LSB: weewx weather system... Nov 21 14:11:30 pi4 weewx[3164] INFO __main__: Initializing weewx version 4.5.1 Nov 21 14:11:30 pi4 weewx[3164] INFO __main__: Using Python 3.7.3 (default, Jan 22 2021, 20:04:44) #012[GCC 8.3.0] Nov 21 14:11:30 pi4 weewx[3164] INFO __main__: Platform Linux-5.10.17-v7l+-armv7l-with-debian-10.10 Nov 21 14:11:30 pi4 weewx[3164] INFO __main__: Locale is 'en_US.UTF-8' Nov 21 14:11:30 pi4 weewx[3164] INFO __main__: PID file is /var/run/weewx.pid Nov 21 14:11:30 pi4 weewx[3168] INFO __main__: Using configuration file /etc/weewx/weewx.conf Nov 21 14:11:30 pi4 weewx[3168] INFO __main__: Debug is 0 Nov 21 14:11:30 pi4 weewx[3168] INFO weewx.engine: Loading station type SocketLogger (user.socketlogger) Nov 21 14:11:30 pi4 /weewxd: SocketLogger: Connecting to socket on localhost port 2999 Nov 21 14:11:30 pi4 /weewxd: SocketLogger: Connected to host localhost on port 2999 Nov 21 14:11:30 pi4 weewx[3168] INFO weewx.engine: StdConvert target unit is 0x1 Nov 21 14:11:30 pi4 weewx[3152]: Starting weewx weather system: weewx. Nov 21 14:11:30 pi4 systemd[1]: Started LSB: weewx weather system. Nov 21 14:11:30 pi4 weewx[3168] INFO weewx.manager: Daily summaries at V2.0. Patching to V4.0 Nov 21 14:11:30 pi4 weewx[3168] INFO weewx.manager: recalculate_weights: Using database 'weewx.sdb' It took almost 10 minutes, but I have data in weewx again. Op dinsdag 7 juli 2020 om 21:21:50 UTC+2 schreef [email protected]: > THanks, I found the weewx-interceptor and installed it in listening mode. > Now everything works fine. > -- 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/847360fb-843b-4110-b128-528a8ade843an%40googlegroups.com.
