Hi Gary,

I disabled my data service and the errors still were there. See the logfile 
in attachment.

So I assumed that there is a problem with the vantage driver in combination 
with my hardware.
So I changed in weewx.conf to
    # If possible, new archive records are downloaded from the station
    # hardware. If the hardware does not support this, then new archive
    # records will be generated in software.
    # Set the following to "software" to force software record generation.
    record_generation = software
this solves the problem with the logging errors.

With the "unable to add records" problem solved I finished my data service 
- also in attachment - which seems to be working now :).

Back to the issue with the archive records - I read in the customization 
guide, that in case of the record generation is set hardware, the archive 
records are directly genereted by the hardware. So I assume, that my 
hardware emitts an archive record to often.
As I have seen in the vantage protocol descriptin the archive data can be 
requested via the DMPAFT command and sending the timestamp of the last 
received archive record.
I think somewhere is a slight different behaviour between my WeatherDuino 
and an original Davis device - because the developper of the WeatherDuino 
says the emulation is compatible with the original Davis software and 
nearly each other weather software. I can confirm this.
Maybe it is necessary to use some kind of port sniffer to check the 
communication or do you know if there are additional debug outputs of the 
driver available.

Best regards,
engolling

Am Dienstag, 19. März 2019 00:57:16 UTC+1 schrieb gjr80:
>
> On Tuesday, 19 March 2019 07:57:06 UTC+10, engolling wrote:
>>
>> Hi Gary,
>> thanks for your patience.
>>
>> This is not normal operation. Because something it triggering an archive 
>>> record to be saved every few seconds the NEW_ARCHIVE_RECORD event is also 
>>> triggered which causes your service to fire as well. The issue here is not 
>>> your service but whatever is causing this archive record to be written 
>>> every few seconds. I suggest we step back a bit and get a clear picture of 
>>> how your system is configured and what it is running.
>>>
>>
>> I was wondering where these errors where coming from and I already tried 
>> to get more information about it. I found somewhere a statement that is not 
>> too bad and might happen if a very narrow saving interval is used. But now 
>> I increasingly understand...
>>
>
> Errors involving 'Unable to add record' are not good and are a sign 
> something is wrong, at the very least you are wasting processor time, 
> something you probably should avoid with such a short archive interval. A 
> short archive interval should not be the cause in itself
>
> On Tuesday, 19 March 2019 08:21:12 UTC+10, engolling wrote:
>
>> One more thing - I do not own a original davis station - I'm using a 
>> WeatherDuino, emulating a davis station for import of "standard" data.
>> https://www.meteocercal.info/forum/index.php
>>
>
> OK, not saying that is the issue but it is another complicating factor. 
> Your weewx.conf looks fine and I don't see anything in your service that 
> would be causing the archive record problem. Let's step right back to 
> basics and disable your service so that you have WeeWX running just the 
> vantage driver to talk the WeatherDuino. To do this:
>
> 1. edit weewx.conf, and change:
>
> [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 = user.WeeWx_WeatherDuino_Logger_plugin.WeeWxService
> ,
>         process_services = weewx.engine.StdConvert, weewx.engine.
> StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate
>
> to
>
> [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 = , #
> user.WeeWx_WeatherDuino_Logger_plugin.WeeWxService,
>         process_services = weewx.engine.StdConvert, weewx.engine.
> StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate
>
> 2. save weewx.conf
>
> 3. restart WeeWX and let it run for 10 minutes or so then take a copy of 
> the log from when WeeWX was restarted and post it here, make sure you 
> capture the full WeeWX startup
>
> This should show us whether the WeatherDuino/vantage driver is causing the 
> problem or if it is your service.
>
> Gary
>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mar 19 07:20:13 WeatherDuinoPi weewx[13703]: engine: Initializing weewx version 
3.8.2
Mar 19 07:20:13 WeatherDuinoPi weewx[13703]: engine: Using Python 2.7.13 
(default, Sep 26 2018, 18:42:22) #012[GCC 6.3.0 20170516]
Mar 19 07:20:13 WeatherDuinoPi weewx[13703]: engine: Platform 
Linux-4.14.71+-armv6l-with-debian-9.8
Mar 19 07:20:13 WeatherDuinoPi weewx[13703]: engine: Locale is 'en_GB.UTF-8'
Mar 19 07:20:13 WeatherDuinoPi weewx[13703]: engine: pid file is 
/var/run/weewx.pid
Mar 19 07:20:13 WeatherDuinoPi weewx[13692]: Starting weewx weather system: 
weewx.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Using configuration file 
/etc/weewx/weewx.conf
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Loading station type 
Vantage (weewx.drivers.vantage)
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: StdConvert target unit is 
0x10
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: wxcalculate: The following values 
will be calculated: barometer=prefer_hardware, windchill=prefer_hardware, 
dewpoint=prefer_hardware, appTemp=prefer_hardware, rainRate=prefer_hardware, 
windrun=prefer_hardware, heatindex=prefer_hardware, 
maxSolarRad=prefer_hardware, humidex=prefer_hardware, pressure=prefer_hardware, 
inDewpoint=prefer_hardware, ET=prefer_hardware, altimeter=prefer_hardware, 
cloudbase=prefer_hardware
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: wxcalculate: The following 
algorithms will be used for calculations: altimeter=aaNOAA, maxSolarRad=RS
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Archive will use data 
binding wx_binding
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Record generation will be 
attempted in 'hardware'
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Using archive interval of 
60 seconds (specified by hardware)
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Using binding 'wx_binding' 
to database 'weewx.sdb'
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: manager: Starting backfill of 
daily summaries
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: restx: StationRegistry: 
Registration not requested.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: restx: Wunderground: Posting not 
enabled.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: restx: PWSweather: Posting not 
enabled.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: restx: CWOP: Posting not enabled.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: restx: WOW: Posting not enabled.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: restx: AWEKAS: Posting not enabled.
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Starting up weewx version 
3.8.2
Mar 19 07:20:14 WeatherDuinoPi weewx[13707]: engine: Clock error is -0.76 
seconds (positive is fast)
Mar 19 07:20:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:17:00 CET (1552976220) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:20:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:18:00 CET (1552976280) to database 'weewx.sdb'
Mar 19 07:20:17 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:18:00 CET (1552976280) to daily summary in 'weewx.sdb'
Mar 19 07:20:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:19:00 CET (1552976340) to database 'weewx.sdb'
Mar 19 07:20:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:19:00 CET (1552976340) to daily summary in 'weewx.sdb'
Mar 19 07:20:19 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:15:00 CET (1552976100) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:20:19 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:16:00 CET (1552976160) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:20:20 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:17:00 CET (1552976220) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:20:20 WeatherDuinoPi weewx[13707]: engine: Starting main packet loop.
Mar 19 07:21:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:19:00 CET (1552976340) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:21:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:20:00 CET (1552976400) to database 'weewx.sdb'
Mar 19 07:21:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:20:00 CET (1552976400) to daily summary in 'weewx.sdb'
Mar 19 07:21:17 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:16:00 CET (1552976160) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:21:18 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:17:00 CET (1552976220) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:21:58 WeatherDuinoPi weewx[13707]: cheetahgenerator: Generated 9 
files for report StandardReport in 39.12 seconds
Mar 19 07:22:17 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:20:00 CET (1552976400) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:22:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:21:00 CET (1552976460) to database 'weewx.sdb'
Mar 19 07:22:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:21:00 CET (1552976460) to daily summary in 'weewx.sdb'
Mar 19 07:22:20 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:17:00 CET (1552976220) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:22:20 WeatherDuinoPi weewx[13707]: engine: Launch of report thread 
aborted: existing report thread still running
Mar 19 07:23:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:21:00 CET (1552976460) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:23:17 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:22:00 CET (1552976520) to database 'weewx.sdb'
Mar 19 07:23:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:22:00 CET (1552976520) to daily summary in 'weewx.sdb'
Mar 19 07:23:19 WeatherDuinoPi weewx[13707]: engine: Launch of report thread 
aborted: existing report thread still running
Mar 19 07:23:26 WeatherDuinoPi weewx[13707]: imagegenerator: Generated 15 
images for StandardReport in 87.83 seconds
Mar 19 07:23:26 WeatherDuinoPi weewx[13707]: copygenerator: copied 34 files to 
/var/www/html/weewx
Mar 19 07:23:43 WeatherDuinoPi weewx[13707]: ftpgenerator: ftp'd 41 files in 
16.56 seconds
Mar 19 07:24:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:22:00 CET (1552976520) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:24:17 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:23:00 CET (1552976580) to database 'weewx.sdb'
Mar 19 07:24:17 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:23:00 CET (1552976580) to daily summary in 'weewx.sdb'
Mar 19 07:24:18 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:19:00 CET (1552976340) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:24:19 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:20:00 CET (1552976400) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:24:20 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:21:00 CET (1552976460) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:24:20 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:22:00 CET (1552976520) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:24:29 WeatherDuinoPi weewx[13707]: cheetahgenerator: Generated 9 
files for report StandardReport in 8.73 seconds
Mar 19 07:25:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:23:00 CET (1552976580) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:25:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:24:00 CET (1552976640) to database 'weewx.sdb'
Mar 19 07:25:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:24:00 CET (1552976640) to daily summary in 'weewx.sdb'
Mar 19 07:25:20 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:20:00 CET (1552976400) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:25:21 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:21:00 CET (1552976460) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:25:22 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:22:00 CET (1552976520) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:25:22 WeatherDuinoPi weewx[13707]: engine: Launch of report thread 
aborted: existing report thread still running
Mar 19 07:25:58 WeatherDuinoPi weewx[13707]: imagegenerator: Generated 15 
images for StandardReport in 89.15 seconds
Mar 19 07:25:59 WeatherDuinoPi weewx[13707]: copygenerator: copied 17 files to 
/var/www/html/weewx
Mar 19 07:26:10 WeatherDuinoPi weewx[13707]: ftpgenerator: ftp'd 41 files in 
11.03 seconds
Mar 19 07:26:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:24:00 CET (1552976640) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:26:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:25:00 CET (1552976700) to database 'weewx.sdb'
Mar 19 07:26:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:25:00 CET (1552976700) to daily summary in 'weewx.sdb'
Mar 19 07:26:17 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:21:00 CET (1552976460) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:26:18 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:22:00 CET (1552976520) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:26:27 WeatherDuinoPi weewx[13707]: cheetahgenerator: Generated 9 
files for report StandardReport in 8.92 seconds
Mar 19 07:27:17 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:25:00 CET (1552976700) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:27:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:26:00 CET (1552976760) to database 'weewx.sdb'
Mar 19 07:27:18 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:26:00 CET (1552976760) to daily summary in 'weewx.sdb'
Mar 19 07:27:20 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:22:00 CET (1552976520) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:27:20 WeatherDuinoPi weewx[13707]: engine: Launch of report thread 
aborted: existing report thread still running
Mar 19 07:27:55 WeatherDuinoPi weewx[13707]: imagegenerator: Generated 15 
images for StandardReport in 87.98 seconds
Mar 19 07:27:55 WeatherDuinoPi weewx[13707]: copygenerator: copied 17 files to 
/var/www/html/weewx
Mar 19 07:28:06 WeatherDuinoPi weewx[13707]: ftpgenerator: ftp'd 41 files in 
10.74 seconds
Mar 19 07:28:16 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:26:00 CET (1552976760) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:28:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:27:00 CET (1552976820) to database 'weewx.sdb'
Mar 19 07:28:16 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:27:00 CET (1552976820) to daily summary in 'weewx.sdb'
Mar 19 07:28:26 WeatherDuinoPi weewx[13707]: cheetahgenerator: Generated 9 
files for report StandardReport in 8.54 seconds
Mar 19 07:29:18 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:27:00 CET (1552976820) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:29:20 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:28:00 CET (1552976880) to database 'weewx.sdb'
Mar 19 07:29:20 WeatherDuinoPi weewx[13707]: manager: Added record 2019-03-19 
07:28:00 CET (1552976880) to daily summary in 'weewx.sdb'
Mar 19 07:29:22 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:24:00 CET (1552976640) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:29:23 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:25:00 CET (1552976700) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:29:24 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:26:00 CET (1552976760) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:29:26 WeatherDuinoPi weewx[13707]: manager: Unable to add record 
2019-03-19 07:27:00 CET (1552976820) to database 'weewx.sdb': UNIQUE constraint 
failed: archive.dateTime
Mar 19 07:29:26 WeatherDuinoPi weewx[13707]: engine: Launch of report thread 
aborted: existing report thread still running
import syslog
import weewx
from datetime import datetime
from time import strptime
from time import mktime
from weewx.wxengine import StdService
import weewx.units

#First read units from unit line of the export file
filename = '/home/pi/WeatherDuino/WeeWx_Exp.txt'
with open(filename) as f:
    for line,row in enumerate(f.readlines()):
        if line == 0:
            names = row.strip().split(";")
        if line == 1:
            unit_groups = row.strip().split(";")

#Add variable names to unit groups
for n in range(len(names)-1):
    if str(unit_groups[n+1]) != 'none':
        weewx.units.obs_group_dict[str(names[n+1])] = str(unit_groups[n+1])
    
weewx.units.USUnits['group_gas_concentration'] = 'ppm'
weewx.units.MetricUnits['group_gas_concentration'] = 'ppm'
weewx.units.MetricWXUnits['group_gas_concentration'] = 'ppm'
weewx.units.default_unit_format_dict['ppm']  = '%.0f'
weewx.units.default_unit_label_dict['ppm']  = ' ppm'

weewx.units.USUnits['group_dust'] = 'microgramm_per_meter_cubic'
weewx.units.MetricUnits['group_dust'] = 'microgramm_per_meter_cubic'
weewx.units.MetricWXUnits['group_dust'] = 'microgramm_per_meter_cubic'
weewx.units.default_unit_format_dict['microgramm_per_meter_cubic']  = '%.1f'
weewx.units.default_unit_label_dict['microgramm_per_meter_cubic']  = ' \xce\xbcg/m\xc2\xb3'

####################################################################################

class WeeWxService(StdService):
    def __init__(self, engine, config_dict):
        super(WeeWxService, self).__init__(engine, config_dict)      
        d = config_dict.get('WeatherDuino_logger_service', {})
        self.filename = d.get('filename', '/home/pi/WeatherDuino/WeeWx_Exp.txt')
        syslog.syslog(syslog.LOG_INFO, "WeatherDuino: using %s" % self.filename)
        self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)
        self.last_rain = [None, None, None, None]
    
    def read_file(self, event):
        try:
            #Read data from WeatherDuino Logger output txt file
            with open(self.filename) as f:
                for line,row in enumerate(f.readlines()):
                    if line == 0:
                        names = row.strip().split(";")
                    if line == 1:
                        units = row.strip().split(";")
                    if line == 2:
                        values = row.strip().split(";")
                        
            #Read timestamp of data and convert it
            timestamp = strptime(values[0], '%Y-%m-%d %H:%M:%S')
            dt = datetime.fromtimestamp(mktime(timestamp))
            #Check if read data is not older than 3 minutes
            if (datetime.now()-dt).total_seconds() < 180:
                syslog.syslog(syslog.LOG_DEBUG, "WeatherDuino: Valid values found")

                #Create index pointer for last_rain buffer list and error handling
                rainind=0
                error_ind = 0
                deltarain = 0

                for n in range(len(values)-1):
                    error_ind = n
                    #Convert transmitted total rain value to rain delta since last WeeWx import
                    if units[n+1] == 'group_rain':
                        #Check if the safe file contains enough entries
                        if rainind < len(self.last_rain):
                            #if yes calculate the rain difference and store the new rain value into the buffer
                            try:
                                #Handle if variable is None after a restart of WeeWx
                                if self.last_rain[rainind] != None:
                                    deltarain = float(values[n+1]) - self.last_rain[rainind]
                                else:
                                    deltarain = None

                                self.last_rain[rainind] = float(values[n+1])
                            except:
                                deltarain = None
                        #If there are not enough entries - for which reason ever - write None to WeeWx and add a entry to the buffer
                        else:
                            deltarain = None

                        #Check the integrity of the data maybe the rain counter of the WeatherDuino has run over or other strange things happened causing ghost rain
                        if deltarain < 0 or deltarain > 30:
                            deltarain = None
                        #Add the value to the WeeWx database
                        #syslog.syslog(syslog.LOG_DEBUG, "WeatherDuino: " + str(names[n+1]) + ": " + str(deltarain))
                        event.record[str(names[n+1])] = deltarain
                        #Shift rain index to handle more rain signals
                        rainind = rainind + 1
                    #Handle all other signals
                    else:
                        event.record[str(names[n+1])] = float(values[n+1])
                        #syslog.syslog(syslog.LOG_DEBUG, "WeatherDuino: " + str(names[n+1]) + ": " + str(values[n+1]))
                        
            #Else throw an exception
            else:
                syslog.syslog(syslog.LOG_ERR, "WeatherDuino: Data is too old. Check logging addon!")

        except Exception, e:
            syslog.syslog(syslog.LOG_ERR, "WeatherDuino: Processing error at positon " + str(names[error_ind+1]))


#################################################################################
import schemas.wview
filename = '/home/pi/WeatherDuino/WeeWx_Exp.txt'

with open(filename) as f:
	for line,row in enumerate(f.readlines()):
		if line == 0:
			names = row.strip().split(";")
schema_WeatherDuino = schemas.wview.schema
for n in range(len(names)-1):
	schema_WeatherDuino = schema_WeatherDuino + [(str(names[n+1]), 'REAL')]

Reply via email to