Ok,my apologies, I have probably led you down a little bit of a path here. units.convert() actually returns a ValueTuple object, to get the actual value we want its value property, so chnage
snow_total = convert(value_vt, event.record['usUnits']) to snow_total = convert(value_vt, event.record['usUnits']).value You won't need the float() around snow_total, self._last_snow and delta. They are already numeric (and delta could well be None) You might also find it easier while troubleshooting to remove the try..except and just let the error cause the usual stack trace generation. This was you will usually get a line number and error description. Gary On Saturday, 14 January 2017 20:50:52 UTC+10, Hartmut Schweidler wrote: > > News > > syslog: > Jan 14 11:38:44 wetterba weewx[27182]: fousb: polling interval is 60 > Jan 14 11:38:44 wetterba weewx[27182]: fousb: found station on USB bus=004 > device=003 > Jan 14 11:38:44 wetterba weewx[27182]: snowdepth: using /home/weewx/snow > Jan 14 11:38:44 wetterba weewx[27182]: engine: StdConvert target unit is > 0x10 > ... > > Jan 14 11:41:11 wetterba weewx[27182]: fousb: changing data format from > 1080 to 3080 > Jan 14 11:41:14 wetterba weewx[27182]: snowdepth: SNOW value of 1.5 > Jan 14 11:41:14 wetterba weewx[27182]: snowdepth: found usUnits of 16 > Jan 14 11:41:14 wetterba weewx[27182]: snowdepth: SYSLOG ERR cannot read > value: 16 > Jan 14 11:41:16 wetterba weewx[27182]: manager: added record 2017-01-14 > 11:41:11 CET (1484390471) to database 'weewx3080' > Jan 14 11:41:16 wetterba weewx[27182]: manager: added record 2017-01-14 > 11:41:11 CET (1484390471) to daily summary in 'weewx3080' > Jan 14 11:41:16 wetterba weewx[27182]: engine: Starting main packet loop. > > my snowhes.py > ... > def newArchiveRecord(self, event): > try: > with open(self.filename) as f: > snow_val = f.read() > > value_vt = ValueTuple(float(snow_val), 'cm', 'group_snow') > > snow_total = convert(value_vt, event.record['usUnits']) > > 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) > > > in "event.record['usUnits']" = 16 = METRIC = 0x10 > _last_snow ==> self._last_snow = None > > -- 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.