At present the code includes 'testing code' that I've used to confirm that the various unit transformations all work, and this is controlled by a single class boolean variable. Is it better to leave this code in there for others to check things out or should it be removed to make the code easier to understand?
[XC0422]
driver = user.xc0422
ip_address_mask = "192.168.1.255"
retry_count = 5
socket_timeout = 5
# systemd configuration for weewx
[Unit]
Description=weewx weather system
Requires=syslog.service
Requires=ntp.service
After=syslog.service
After=ntp.service
#RequiresMountsFor=/home
[Service]
ExecStart=/usr/bin/weewxd --daemon --pidfile=/var/run/weewx.pid /etc/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=60
Type=simple
PIDFile=/var/run/weewx.pid
#User=weewx
#Group=weewx
[Install]
WantedBy=multi-user.target
The "Restart=always" guarantees that weewx will get restarted, and the "RestartSec=60" guarantees that my wifi will have had a chance to reset before going into a start-crash-start-crash endless loop.
So far, the above has been running for a couple of days without issue. THANKS Susan (and the developers of weewx!).
dr__bob
Dr Bob (name taken from the old Muppet sketch per chance???),
I can put in a delay (with the delay length driven by an optional parameter with a default of 5 seconds). I must admit that the network traffic didn't bother me on my home local network (especially when you look at the garbage my Apple TV puts onto the network) but this is a good idea.
Also I'll add in the suggestion for the systemctl file. In the 'readme' I mention that you should put in references to make sure the network is up and running so the Weewx daemon will not cause problems on startup.
Any thoughts about sampling the SDETUP packet more often to detect console unit changes or is just telling people to restart Weewx OK?
Thanks for all of the feedback - brilliant!Mike - I was a bit wary of claiming too much 'copyright' as I must admit I've "borrowed" quite a bit from your "pmon" extension.I noticed that using the "wee_extension" install method only put into the config file the lines in 'config' section of the 'install.py' file. However the driver itself has the 'confeditor_loader' function that I must have got be run sometime in the past (just putting the code in the directory and using the 'wee_config' reconfigure to switch to the new driver perhaps???) and that has commented lines which I think is much better.
I'll also change the name. the XC0422 was the only clone that I had access to and I didn't want to make claims that I could not back up by calling it anything else. However it would seem that it does work on other 'clones' and so using the original name woudl be netter.Dr Bob (name taken from the old Muppet sketch per chance???), I can put in a delay (with the delay length driven by an optional parameter with a default of 5 seconds). I must admit that the network traffic didn't bother me on my home local network (especially when you look at the garbage my Apple TV puts onto the network) but this is a good idea.
Also I'll add in the suggestion for the systemctl file. In the 'readme' I mention that you should put in references to make sure the network is up and running so the Weewx daemon will not cause problems on startup.
Gary - Thanks for the suggestions. I'll read to read up on 'markdown' and give that a go.Back with another go shortly. Also thinking about using the 'HISTORY' data to see if there are gaps in the Weewx databse that can be filled in by the console, but that will be V2.Any thoughts about sampling the SDETUP packet more often to detect console unit changes or is just telling people to restart Weewx OK?Susan
Also I'll add in the suggestion for the systemctl file. In the 'readme' I mention that you should put in references to make sure the network is up and running so the Weewx daemon will not cause problems on startup.
it would be better if you do not. instead of applying that band-aid, make the driver more robust. you should retry the network connections, and if the retries fail more than max_tries times, then you raise a weewx.WeeWxIOError exception. then weewx handles it as it does for any other driver.
remember that not everyone uses systemd (*bsd, windows and macos do not even have systemd)
Jan 18 20:07:14 rpi weewx[26548]: engine: Caught unrecoverable exception in engine:
Jan 18 20:07:14 rpi weewx[26548]: **** [Errno 101] Network is unreachable
Jan 18 20:07:14 rpi weewx[26548]: **** Traceback (most recent call last):
Jan 18 20:07:14 rpi weewx[26548]: **** File "/usr/share/weewx/weewx/engine.py", line 847, in main
Jan 18 20:07:14 rpi weewx[26548]: **** engine.run()
Jan 18 20:07:14 rpi weewx[26548]: **** File "/usr/share/weewx/weewx/engine.py", line 186, in run
Jan 18 20:07:14 rpi weewx[26548]: **** for packet in self.console.genLoopPackets():
Jan 18 20:07:14 rpi weewx[26548]: **** File "/usr/share/weewx/user/xc0422.py", line 128, in genLoopPackets
Jan 18 20:07:14 rpi weewx[26548]: **** (self.ipAddressMask, UDP_BROADCAST_PORT))
Jan 18 20:07:14 rpi weewx[26548]: **** error: [Errno 101] Network is unreachable
Jan 18 20:07:14 rpi weewx[26548]: **** Exiting.
Jan 18 20:08:15 rpi weewx[26838]: engine: Initializing weewx version 3.6.2
Clearly the sock.sendto failed here, since the wifi went down and there was no network at that point. weewx then crashes, and a minute later systemd started it up again. (And it probably got to that point because the recv further down the while loop failed.) So a try, except bracketing the sendto would help. With a configurable delay? With a configurable number of retries? But I've really got to figure out why my cable modem apparently periodically restarts.
So a try, except bracketing the sendto would help. With a configurable delay? With a configurable number of retries? But I've really got to figure out why my cable modem apparently periodically restarts.
'retry_wait' : 5, 'driver' : 'user.HP1000Driver'}},
Thanks for the feedback. I'll plead 'guilty' to not bumping the version number, but I've just downloaded and expanded the file I attached above and the line in the 'install.py' file that I think drives all this is:'retry_wait' : 5,'driver' : 'user.HP1000Driver'}},
Am I not looking in the right place?
*** HP1000.py 2017-02-05 02:15:01.000000000 -0800
--- /usr/share/weewx/user/HP1000.py 2017-02-20 16:52:10.466575082 -0800
***************
*** 237,241 ****
loginf('Established contact at %s' %
! datetime.datetime.now().strftime('%d/%m/%y H:%M:%S'))
# Now read the SETUP packet to find the current value units
--- 237,241 ----
loginf('Established contact at %s' %
! datetime.datetime.now().strftime('%d/%m/%y %H:%M:%S'))
# Now read the SETUP packet to find the current value units
I think I'm nearly ready to release this but I'd still like a comment on hwo to best handle the new version (V3.7.0)
Bob - I don't think that the line you mention needs to be changed. As far as I now it is the name of the class (prefixed by the 'user.' folder which becomes part of the nested class when it is imported) which does have the 'Driver' text at the end of it. It has been that way for a while and has always worked for me.
2) the 'driver' field refers to the python module in which the driver code resides. so you want 'user.hp1000' (assuming that you lowercase the filename)
Ed at Ambient says the ws-2902 doesn't have a communications protocol. ;^)
telnet 192.168.1.16 45000
Trying 192.168.1.16...
Connected to 192.168.1.16.
Escape character is '^]'.