How to set WeeWx to restart after local network returns from being offline

315 views
Skip to first unread message

Ben W.

unread,
May 18, 2024, 3:45:10 PM5/18/24
to weewx-user
Hello!

Every so often, my home network (through eero) will upgrade causing devices to go offline/lose connection for a few minutes.

The last two times my eero/network was updated in the early morning, WeeWx stopped when the connection was lost (expected). I cannot find how to set WeeWx to restart once the network is available again.

The log from the most recent upgrade around 02:41 on the 15th:



May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.restx: PWSWeather: Published record 2024-05-15 02:40:00 CDT (1715758800)
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.cheetahgenerator: Generated 8 files for report SeasonsReport in 0.38 seconds
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.imagegenerator: Generated 17 images for report SeasonsReport in 0.21 seconds
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.reportengine: Copied 0 files to /var/www/html/weewx
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.cheetahgenerator: Generated 6 files for report SmartphoneReport in 0.02 seconds
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.imagegenerator: Generated 6 images for report SmartphoneReport in 0.05 seconds
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.reportengine: Copied 0 files to /var/www/html/weewx/smartphone
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.cheetahgenerator: Generated 1 files for report MobileReport in 0.01 seconds
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.imagegenerator: Generated 4 images for report MobileReport in 0.03 seconds
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.reportengine: Copied 0 files to /var/www/html/weewx/mobile
May 15 02:40:24 rpi5  weewxd[101529]: INFO weewx.cheetahgenerator: Generated 13 files for report StandardReport in 0.22 seconds
May 15 02:40:25 rpi5  weewxd[101529]: INFO weewx.imagegenerator: Generated 12 images for report StandardReport in 0.11 seconds
May 15 02:40:25 rpi5  weewxd[101529]: INFO weewx.reportengine: Copied 0 files to /var/www/html/weewx
May 15 02:40:25 rpi5  weewxd[101529]: INFO weewx.cheetahgenerator: Generated 12 files for report Belchertown in 0.38 seconds
May 15 02:40:25 rpi5  weewxd[101529]: INFO weewx.reportengine: Copied 3 files to /var/www/html/weewx/belchertown
May 15 02:41:06 rpi5  weewxd[101529]: ERROR user.gw1000: Failed to obtain response to command 'CMD_GW1000_LIVEDATA' after 3 attempts
May 15 02:41:06 rpi5  weewxd[101529]: ERROR user.gw1000: Unable to obtain live sensor data
May 15 02:41:06 rpi5  weewxd[101529]: INFO weewx.engine: Main loop exiting. Shutting engine down.
May 15 02:41:06 rpi5  weewxd[101529]: INFO weewx.engine: Shutting down StdReport thread
May 15 02:41:06 rpi5  weewxd[101529]: ERROR user.gw1000: Failed to obtain response to command 'CMD_GW1000_LIVEDATA' after 3 attempts
May 15 02:41:06 rpi5  weewxd[101529]: ERROR user.gw1000: Unable to obtain live sensor data
May 15 02:41:07 rpi5  weewxd[101529]: INFO user.gw1000: GatewayCollector thread has been terminated
May 15 02:41:17 rpi5  weewxd[101529]: ERROR user.gw1000: Unable to shut down GatewayCollector thread
May 15 02:41:17 rpi5  weewxd[101529]: CRITICAL __main__: Caught WeeWxIOError: Failed to obtain response to command 'CMD_GW1000_LIVEDATA' after 3 attempts
May 15 02:41:17 rpi5  weewxd[101529]: CRITICAL __main__:     ****  Waiting 60.0 seconds then retrying...
May 15 02:41:27 rpi5  weewxd[101529]: ERROR user.gw1000: Failed to obtain response to command 'CMD_GW1000_LIVEDATA' after 3 attempts
May 15 02:41:27 rpi5  weewxd[101529]: ERROR user.gw1000: Unable to obtain live sensor data
May 15 02:42:17 rpi5  weewxd[101529]: INFO __main__: retrying...
May 15 02:42:17 rpi5  weewxd[101529]: INFO weewx.engine: Loading station type GW1000 (user.gw1000)
May 15 02:42:17 rpi5  weewxd[101529]: INFO user.gw1000: GatewayDriver: version is 0.6.1
May 15 02:42:17 rpi5  weewxd[101529]: INFO user.gw1000:      device address is 192.168.7.206:45000
May 15 02:42:17 rpi5  weewxd[101529]: INFO user.gw1000:      poll interval is 20 seconds
May 15 02:42:39 rpi5  weewxd[101529]: ERROR user.gw1000: Failed to obtain response to command 'CMD_READ_STATION_MAC' after 3 attempts
May 15 02:42:39 rpi5  weewxd[101529]: ERROR weewx.engine: Import of driver failed: Failed to obtain response to command 'CMD_READ_STATION_MAC' after 3 attempts (<class 'user.gw1000.GWIOError'>)
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****  Traceback (most recent call last):
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/usr/share/weewx/weewx/engine.py", line 115, in setupStation
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      self.console = loader_function(config_dict, self)
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 1907, in loader
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      return GatewayDriver(**config_dict[DRIVER_NAME])
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 2523, in __init__
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      super(GatewayDriver, self).__init__(**stn_dict)
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 1156, in __init__
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      self.collector = GatewayCollector(ip_address=self.ip_address,
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 2818, in __init__
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      self.device = GatewayDevice(ip_address=ip_address, port=port,
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 6240, in __init__
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      self.api = GatewayApi(ip_address=ip_address,
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 4981, in __init__
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      self.mac = self.get_mac_address()
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****                 ^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 5416, in get_mac_address
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      response = self.send_cmd_with_retries('CMD_READ_STATION_MAC')
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****    File "/etc/weewx/bin/user/gw1000.py", line 5670, in send_cmd_with_retries
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****      raise GWIOError(_msg)
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL weewx.engine:     ****  user.gw1000.GWIOError: Failed to obtain response to command 'CMD_READ_STATION_MAC' after 3 attempts
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL __main__: Unable to load driver: Failed to obtain response to command 'CMD_READ_STATION_MAC' after 3 attempts
May 15 02:42:39 rpi5  weewxd[101529]: CRITICAL __main__:     ****  Exiting...
May 15 02:42:40 rpi5  systemd[1]: weewx.service: Main process exited, code=exited, status=4/NOPERMISSION
May 15 02:42:40 rpi5  systemd[1]: weewx.service: Failed with result 'exit-code'.
May 15 02:42:40 rpi5  systemd[1]: weewx.service: Consumed 2h 32min 7.226s CPU time.




It took me three days to realize it wasn't running. I'm back online now but would like to avoid those gaps going forward.

Thanks!

p q

unread,
May 18, 2024, 3:56:58 PM5/18/24
to weewx...@googlegroups.com
Here's a dumb suggestion. I'm sure there will be smarter answers. Restart weewx every day at 2am with a cron job whether it needs it or not.

--
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/b48ffc02-f9af-4873-bd09-e1971d3ff08an%40googlegroups.com.


--
Peter Quinn
(415)794-2264

vince

unread,
May 18, 2024, 5:32:36 PM5/18/24
to weewx-user
At the top of weewx.conf add "loop_on_init = True" to have it try basically continually.   Until 5.1 comes out you'll need to grab an updated weewxd.py and overwrite your existing 5.x copy of that file so the option works.   The latest version is at https://raw.githubusercontent.com/weewx/weewx/master/src/weewxd.py if you want to grab it sooner rather than later.

Worked for me here vs. the ecowitt driver under similar circumstances when I needed to take my network offline for a bit to update firmware on the network gear....

Ben W.

unread,
May 19, 2024, 8:27:49 AM5/19/24
to weewx-user
Sometimes simple is best! I'll look at cron and possibly doing something like that - thank you!

Ben W.

unread,
May 19, 2024, 8:33:50 AM5/19/24
to weewx-user
Thanks! I have  loop_on_init = 1 right now per the documentation. I will change it to "True" to give that a shot. I"m a bit lost with the rest of your response, but I'll look into that more. Thank you!

vince

unread,
May 19, 2024, 12:00:17 PM5/19/24
to weewx-user
You need to replace the weewxd.py file with the newer one for the loop_on_init switch to work.  There's a bug in the previous versions.

Susan Mackay

unread,
May 19, 2024, 10:42:17 PM5/19/24
to weewx-user
I use the (sometimes much maligned) systemd and have in there that it must (re)start after the NFS network drive that I use (the system is a RPi4 with the SD card is set to be Read Only and in-memory logging) is fully mounted.
Just an alternative approach perhaps (or 'belts and braces')
Susan

Ben W.

unread,
Jul 5, 2024, 8:33:00 AM7/5/24
to weewx-user
Hello!
Since 5.1 came out "yesterday", it looks like this issue was resolved per the change log. I will disable the cron job of restarting the service every morning now.

On Saturday, May 18, 2024 at 4:32:36 PM UTC-5 vince wrote:

Ben W.

unread,
Jul 9, 2024, 1:53:33 PM7/9/24
to weewx-user
Hello!
I wanted to confirm that the update worked. As previously noted, I disabled the CRON job to restart weewx every day.  My network had a scheduled update between 2 & 3 AM yesterday and can confirm that it restarted itself!

Thanks again for your help!
Ben

Reply all
Reply to author
Forward
0 new messages