> > Hallo > my plan [snow] and [snowRate] , "cm", "group_snow"
1. /home/weewx/snow value 1.5 (cm) snow --> it is the value of the file snow 2. snowhes.py reads the value of [snow] (1.5) 3. Write the value 1.5 to database (1.5 cm) as [snowRate] --> the result of the current snow 4. and find the value between current 1.5 (cm) [snowRate] in database an the value snow current /home/weewx/snow 5. the 'delta' [snowRate] and [snow] value 1.5 - 1.5 result 0.0 6. the result 0.0 write as [snow] in to database I hope to be able to represent 1. $current.snowl = 0.0 cm 2. Today 1.5 cm snow 3. last snow by change "lastrain.py" on 10.01.2017 09:00 1 day, 12 hours, 34 minutes ago and now the syslog result Jan 14 13:06:11 wetterba weewx[2651]: snowdepth: SNOW value of 1.5 Jan 14 13:06:11 wetterba weewx[2651]: snowdepth: found usUnits of 16 Jan 14 13:06:11 wetterba weewx[2651]: engine: Caught unrecoverable exception in engine: Jan 14 13:06:11 wetterba weewx[2651]: **** 16 Jan 14 13:06:11 wetterba weewx[2651]: **** Traceback (most recent call last): Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/engine.py", line 847, in main Jan 14 13:06:11 wetterba weewx[2651]: **** engine.run() Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/engine.py", line 158, in run Jan 14 13:06:11 wetterba weewx[2651]: **** self.dispatchEvent(weewx.Event(weewx.STARTUP)) Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/engine.py", line 222, in dispatchEvent Jan 14 13:06:11 wetterba weewx[2651]: **** callback(event) Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/engine.py", line 501, in startup Jan 14 13:06:11 wetterba weewx[2651]: **** self._catchup(self.engine.console.genStartupRecords) Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/engine.py", line 606, in _catchup Jan 14 13:06:11 wetterba weewx[2651]: **** origin='hardware')) Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/engine.py", line 222, in dispatchEvent Jan 14 13:06:11 wetterba weewx[2651]: **** callback(event) Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/user/snowhes.py", line 57, in newArchiveRecord Jan 14 13:06:11 wetterba weewx[2651]: **** snow_total = convert(value_vt, event.record['usUnits']).snow_val Jan 14 13:06:11 wetterba weewx[2651]: **** File "/home/weewx/bin/weewx/units.py", line 1189, in convert Jan 14 13:06:11 wetterba weewx[2651]: **** conversion_func = conversionDict[val_t[1]][target_unit_type] Jan 14 13:06:11 wetterba weewx[2651]: **** KeyError: 16 Jan 14 13:06:11 wetterba weewx[2651]: **** Exiting. my file snowhes.py """Put this file, snow.py, in the weewx 'user' directory, then modify weewx.conf with something like this: [SnowDepth] filename = /home/weewx/snow To use as a service: [Engine] [[Service]] data_services = user.snowhes.SnowDepth """ import syslog import weewx from weewx.engine import StdService from weewx.units import ValueTuple, convert class SnowDepth(StdService): def __init__(self, engine, config_dict): super(SnowDepth, self).__init__(engine, config_dict) self._last_snow = 0.0 d = config_dict.get('SnowDepth', {}) self.filename = d.get('filename', '/home/weewx/snow') syslog.syslog(syslog.LOG_INFO, "snowdepth: using %s" % self.filename) self.bind(weewx.NEW_ARCHIVE_RECORD, self.newArchiveRecord) def newArchiveRecord(self, event): #try: with open(self.filename) as f: snow_val = f.read() syslog.syslog(syslog.LOG_DEBUG, "snowdepth: found value of %s" % snow_val) syslog.syslog(syslog.LOG_INFO, "snowdepth: SNOW value of %s" % snow_val) # Convert our value to a type ValueTuple. We know it is in cm and # let's use group_snow (could use group_length too) value_vt = ValueTuple(float(snow_val), 'cm', 'group_snow') # Now convert the cm value to the same units as used in our record # The unit system of the record is in the records 'usUnits' field snow_total = convert(value_vt, event.record['usUnits']).snow_val #event.record['some_field_name'] = value_conv syslog.syslog(syslog.LOG_INFO, "snowdepth: found SNOW-value of %s" % snow_total) delta = weewx.wxformulas.calculate_rain(snow_total, self._last_snow) self._last_snow = float(snow_total) event.record['snowRate'] = float(self._last_snow) event.record['snow'] = float(delta) #except Exception, e: syslog.syslog(syslog.LOG_ERR, "snowdepth: SYSLOG ERR cannot read value: %s" % e) -- 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.