I set your code up as a service following the vaporpressure.py example and get the following errors on restart: -
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** File "/usr/share/weewx/weewxd", line 148, in main
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** engine = weewx.engine.StdEngine(config_dict)
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** File "/usr/share/weewx/weewx/engine.py", line 81, in __init__
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** self.loadServices(config_dict)
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** File "/usr/share/weewx/weewx/engine.py", line 153, in loadServices
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** obj = weeutil.weeutil.get_object(svc)(self, config_dict)
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** File "/usr/share/weewx/user/lastnonzero.py", line 84, in __init__
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** self.nz = LastNonZero(algorithm)
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** TypeError: LastNonZero() takes no arguments
Nov 17 17:39:15 raspberrypi python3[7172]: weewx[7172] CRITICAL __main__: **** Exiting.
#
# Copyright (c) 2020 Tom Keffer <
tke...@gmail.com>
#
# See the file LICENSE.txt for your full rights.
#
"""This example shows how to extend the XTypes system with a new type, lastnonzero, the last non-null or non-zero in a record
REQUIRES WeeWX V4.2 OR LATER!
To use:
1. Stop weewxd
2. Put this file in your user subdirectory.
3. In weewx.conf, subsection [Engine][[Services]], add LastNonZero to the list
"xtype_services". For example, this means changing this
[Engine]
[[Services]]
xtype_services = weewx.wxxtypes.StdWXXTypes, weewx.wxxtypes.StdPressureCooker, weewx.wxxtypes.StdRainRater
to this:
[Engine]
[[Services]]
xtype_services = weewx.wxxtypes.StdWXXTypes, weewx.wxxtypes.StdPressureCooker, weewx.wxxtypes.StdRainRater, user.lastnonzero.LastNonZeroService
4. Optionally, add the following section to weewx.conf:
[LastNonZero]
algorithm = simple # Or tetens
5. Restart weewxd
"""
from weewx.engine import StdService
import weedb
import weewx.xtypes
import datetime