syslog.syslog(syslog.LOG_DEBUG, "WeatherDuino: " + str(names[n+1]) + ": " + str(deltarain))
event.record[str(names[n+1])] = float(deltarain)Mar 3 11:56:16 WeatherDuinoPi weewx[1366]: WeatherDuino: Rain_RG11: 0.17716535433
syslog.syslog(syslog.LOG_DEBUG, "WeatherDuino: " + str(names[n+1]) + ": " + str(10))
event.record[str(names[n+1])] = 10# 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 = user.WeeWx_WeatherDuino_Logger_plugin.WeeWxService,
process_services = weewx.engine.StdConvert, weewx.engine.StdCalibrate, weewx.engine.StdQC, weewx.wxservices.StdWXCalculate
archive_services = weewx.engine.StdArchive
restful_services = weewx.restx.StdStationRegistry, weewx.restx.StdWunderground, weewx.restx.StdPWSweather, weewx.restx.StdCWOP, weewx.restx.StdWOW, weewx.restx.StdAWEKAS
report_services = weewx.engine.StdPrint, weewx.engine.StdReport # Because the Davis stations do not offer bucket tips in LOOP data, we
# must calculate it by looking for changes in rain totals. This won't
# work for the very first rain packet.
if self.save_monthRain is None:
delta = None
else:
delta = loop_packet['monthRain'] - self.save_monthRain
# If the difference is negative, we're at the beginning of a month.
if delta < 0: delta = None
loop_packet['rain'] = delta
self.save_monthRain = loop_packet['monthRain']
return loop_packetclass SomeDriver():
def __init__():
....
self.last_rain = None
....
def get_delta_rain(cumulative_rain):
if self.last_rain is not None:
delta_rain = cumulative_rain - self.last_rain
else:
delta_rain =None
self.last_rain = cumulative_rain
return delta_rain$ sqlite3 /home/weewx/archive/weewx.sdb
sqlite> .schema archive
<schema will be listed here>
sqlite> .qHello Gary,
thanks fot your efforts. You are right with your description how my code should work.
Let's say my main problem is that I know how I construct software in principle, but my python knowledgde is not very good, so in order to safe the last cumulative rain value my only solution was to write it into a file. Otherwise I tought the value might get lost between executing the data service
I will try to 'buffer' my last rain value in a variable as you describe it and give you feedback.
But I still think WeeWx does not accumulate correctly in my case, because im nearly 100% sure, that I have checked that my (indeed strange) code emits the values correctly.
My schema looks like this - I think it is fine.
sqlite> .schema archive
CREATE TABLE archive (`dateTime` INTEGER NOT NULL UNIQUE PRIMARY KEY, `usUnits` INTEGER NOT NULL, `interval` INTEGER NOT NULL, `barometer` REAL, `pressure` REAL, `altimeter` REAL, `inTemp` REAL, `outTemp` REAL, `inHumidity` REAL, `outHumidity` REAL, `windSpeed` REAL, `windDir` REAL, `windGust` REAL, `windGustDir` REAL, `rainRate` REAL, `rain` REAL, `dewpoint` REAL, `windchill` REAL, `heatindex` REAL, `ET` REAL, `radiation` REAL, `UV` REAL, `extraTemp1` REAL, `extraTemp2` REAL, `extraTemp3` REAL, `soilTemp1` REAL, `soilTemp2` REAL, `soilTemp3` REAL, `soilTemp4` REAL, `leafTemp1` REAL, `leafTemp2` REAL, `extraHumid1` REAL, `extraHumid2` REAL, `soilMoist1` REAL, `soilMoist2` REAL, `soilMoist3` REAL, `soilMoist4` REAL, `leafWet1` REAL, `leafWet2` REAL, `rxCheckPercent` REAL, `txBatteryStatus` REAL, `consBatteryVoltage` REAL, `hail` REAL, `hailRate` REAL, `heatingTemp` REAL, `heatingVoltage` REAL, `supplyVoltage` REAL, `referenceVoltage` REAL, `windBatteryStatus` REAL, `rainBatteryStatus` REAL, `outTempBatteryStatus` REAL, `inTempBatteryStatus` REAL, `AVG_Rcv_RX0` REAL, `AVG_Rcv_RX1` REAL, `AVG_Rcv_RX2` REAL, `BatVolt_0` REAL, `SysTemp_0` REAL, `Rsfan_0` REAL, `PacketsSentPerHour_0` REAL, `Snow_Height` REAL, `BatVolt_1` REAL, `SysTemp_1` REAL, `Rsfan_1` REAL, `PacketsSentPerHour_1` REAL, `BatVolt_2` REAL, `SysTemp_2` REAL, `Rsfan_2` REAL, `PacketsSentPerHour_2` REAL, `Soil_Temp_Full1` REAL, `Soil_Temp_Full2` REAL, `Soil_Temp_Full3` REAL, `Soil_Temp_Full4` REAL, `AQI_PM1_0` REAL, `AQI_PM2_5` REAL, `AQI_PM10_0` REAL, `AQI_Index` REAL, `AQI_Temp` REAL, `AQI_Hum` REAL, `CO2` REAL, `GAS_2` REAL, `WiFi_T0` REAL, `WiFi_H0` REAL, `Signal_Quality_TX0` REAL, `Signal_Quality_TX1` REAL, `Signal_Quality_TX2` REAL, `Rain_RG11` REAL, `Rain_Rate_RG11` REAL, `Rain_TX2` REAL, `Rain_Rate_TX2` REAL);
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 = [] self.bind(weewx.NEW_LOOP_PACKET, self.read_file)Hi Gary,
maybe I have found my problem after looking at my code and your advices again.
Because it seems that I have bound my additional signals to the archive record and not to the LOOP packet
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 = []
But the logfile tells me my plugin is executed in a frequency like the loop packets:
Mar 17 23:22:19 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values found
Mar 17 23:22:23 WeatherDuinoPi weewx[7972]: manager: Added record 2019-03-17 23:21:00 CET (1552861260) to database 'weewx.sdb'
Mar 17 23:22:23 WeatherDuinoPi weewx[7972]: manager: Added record 2019-03-17 23:21:00 CET (1552861260) to daily summary in 'weewx.sdb'
Mar 17 23:22:24 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values found
Mar 17 23:22:27 WeatherDuinoPi weewx[7972]: manager: Unable to add record 2019-03-17 23:17:00 CET (1552861020) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 17 23:22:27 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values found
Mar 17 23:22:30 WeatherDuinoPi weewx[7972]: manager: Unable to add record 2019-03-17 23:18:00 CET (1552861080) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 17 23:22:30 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values found
Mar 17 23:22:33 WeatherDuinoPi weewx[7972]: manager: Unable to add record 2019-03-17 23:19:00 CET (1552861140) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 17 23:22:33 WeatherDuinoPi weewx[7972]: WeatherDuino: Valid values found
According to your answers this should be the problem because in this case I have to take care that the rain is only augmented once each minute, right?
Mar 17 23:22:27 WeatherDuinoPi weewx[7972]: manager: Unable to add record 2019-03-17 23:17:00 CET (1552861020) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 17 23:22:30 WeatherDuinoPi weewx[7972]: manager: Unable to add record 2019-03-17 23:18:00 CET (1552861080) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 17 23:22:33 WeatherDuinoPi weewx[7972]: manager: Unable to add record 2019-03-17 23:19:00 CET (1552861140) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Should I change the binding toself.bind(weewx.NEW_LOOP_PACKET, self.read_file)
?
Moreover I try to simplify my code as you have proposed, so I added the last line in the init function (is it a function ?) of the class.
My idea was to make a empty list, which I can expand as I want because there can be up to 4 rain values - is this a reasonable solution or do I have to make a list with 4 entries at the beginning?
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.
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...
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.
[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[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 # 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 = softwareMar 26 19:05:17 WeatherDuinoPi weewx[17760]: manager: Added record 2019-03-26 19:04:00 CET (1553623440) to database 'weewx.sdb'
Mar 26 19:05:17 WeatherDuinoPi weewx[17760]: manager: Added record 2019-03-26 19:04:00 CET (1553623440) to daily summary in 'weewx.sdb'
Mar 26 19:05:19 WeatherDuinoPi weewx[17760]: manager: Unable to add record 2019-03-26 19:00:00 CET (1553623200) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 26 19:05:21 WeatherDuinoPi weewx[17760]: manager: Unable to add record 2019-03-26 19:01:00 CET (1553623260) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 26 19:05:31 WeatherDuinoPi weewx[17760]: cheetahgenerator: Generated 9 files for report StandardReport in 10.25 seconds
Mar 26 19:06:19 WeatherDuinoPi weewx[17760]: manager: Added record 2019-03-26 19:05:00 CET (1553623500) to database 'weewx.sdb'
Mar 26 19:06:20 WeatherDuinoPi weewx[17760]: manager: Added record 2019-03-26 19:05:00 CET (1553623500) to daily summary in 'weewx.sdb'
Mar 26 19:06:23 WeatherDuinoPi weewx[17760]: manager: Unable to add record 2019-03-26 19:01:00 CET (1553623260) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTimeMar 18 22:45:18 WeatherDuinoPi weewx[12220]: manager: Unable to add record 2019-03-18 22:43:00 CET (1552945380) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 18 22:45:20 WeatherDuinoPi weewx[12220]: manager: Added record 2019-03-18 22:44:00 CET (1552945440) to database 'weewx.sdb'
Mar 18 22:45:20 WeatherDuinoPi weewx[12220]: manager: Added record 2019-03-18 22:44:00 CET (1552945440) to daily summary in 'weewx.sdb'
Mar 18 22:45:22 WeatherDuinoPi weewx[12220]: manager: Unable to add record 2019-03-18 22:40:00 CET (1552945200) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 18 22:45:24 WeatherDuinoPi weewx[12220]: manager: Unable to add record 2019-03-18 22:41:00 CET (1552945260) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
Mar 18 22:45:25 WeatherDuinoPi weewx[12220]: manager: Unable to add record 2019-03-18 22:42:00 CET (1552945320) to database 'weewx.sdb': UNIQUE constraint failed: archive.dateTime
if dateTime_AugmentedData - event.record[dateTime] < 300:
--> augment_data
--
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/94baea9a-ed38-4e52-9ea1-6ccdb5689960%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<span style="font-family:arial,san
This would mean that the vantage driver polls with a <font s
Mar 26 19:06:23 WeatherDuinoPi weewx[17760<span style=
Mar<span style="color:rgb(0,
import weewx
if event.record['usUnits'] == weewx.US:
# archive record uses US unit system so we need rainfall in inches
event.record['our_new_field'] = rainfall/25.4 if rainfall is not None else None
elif event.record['usUnits'] == weewx.METRIC:
# archive record uses the Metric unit system so we need rainfall in cm
event.record['our_new_field'] = rainfall/10.0 if rainfall is not None else None
elif event.record['usUnits'] == weewx.METRICWX:
# archive record uses the MetricWX unit system so we need rainfall in mm - leave as is
event.record['our_new_field'] = rainfall if rainfall is not None else Noneimport weewx.units
# express our rainfall value as a ValueTuple
rainfall_vt = weewx.units.ValueTuple(rainfall, 'mm', 'group_rain')
# now augment the archive record with the appropriately converted value
event.record['our_new_field'] = weewx.units.convertStd(rainfall_vt, event.record['usUnits'])# express our rainfall value as a ValueTuple
rainfall_vt = weewx.units.ValueTuple(rainfall, 'mm', 'group_rain')
So I started off with the noob variant...
I will change it to the sophisticated procedure you proposed.As I got you rightI have to generate a tuple with the variable holding the actual value, followed by the unit of the signal as it can be found in the units.py dict and ending with the unit group which it belongs to.# express our rainfall value as a ValueTuple
rainfall_vt = weewx.units.ValueTuple(rainfall, 'mm', 'group_rain')
$day.Rain_RG11.sum [[[dayrain]]]
# Make sure the y-axis increment is at least 0.02 for the rain plot
yscale = None, None, 0.02
plot_type = bar
[[[[rain]]]]
aggregate_type = sum
aggregate_interval = 3600
label = Niederschlag (Stundenwerte)
[[[dayrain_RG11]]]
# Make sure the y-axis increment is at least 0.02 for the rain plot
yscale = None, None, 0.02
plot_type = bar
[[[[rain_RG11]]]]
aggregate_type = sum
aggregate_interval = 3600
label = Niederschlag (Stundenwerte)weewx.units.obs_group_dict['Rain_RG11'] = 'group_rain'