Run a script - with parameter? - via WeeWX?

185 views
Skip to first unread message

Rob Cranfill

unread,
Jun 7, 2021, 12:27:41 PM6/7/21
to weewx-user
Apologies if this has been asked - I searched without luck - let me know where to look.....

I would like to have WeeWX tell me when my weather station's battery is low - perhaps running a script once a day that can check the battery status and send me mail if it's low. (All kinds of weirdness happens when it gets that way, which I always forget about and freak out thinking the whole system is boofed, when it's really only a low battery.)

Currently I have a cron job that "screen scrapes" the main page, where the Sensor Status / Battery Status / Transmitter Battery field has the info I want  ("OK", or "LOW", I think). But that's kinda clunky.

The best I can come up with so far is to configure the system to also output a simple HTML page - or maybe just a text file? - with that one value in it, that will simplify the parsing/scraping, but that's still not very elegant.

Or is this just beyond the scope of WeeWX? 

Thanks for any suggestions,
 Rob in Seattle

vince

unread,
Jun 7, 2021, 12:47:09 PM6/7/21
to weewx-user
On Monday, June 7, 2021 at 9:27:41 AM UTC-7 robcr...@gmail.com wrote:
The best I can come up with so far is to configure the system to also output a simple HTML page - or maybe just a text file? - with that one value in it, that will simplify the parsing/scraping, but that's still not very elegant.

Or is this just beyond the scope of WeeWX? 


I dunno, seems pretty elegant and within scope to me.

WeeWX will generate anything you want in any format you want, assuming you create a .tmpl file that makes it happen when the reports are generated.  It would be pretty easy to have a cron job read that file in a script and conditionally alert you somehow such as email.

If you want a pure weewx way, look at https://github.com/weewx/weewx/blob/master/examples/alarm.py for the Alarm example as a starting point, but everything doesn't have to be done purely in weewx.  If it was me, I'd do it the external simple bash script way essentially like you're doing, I'd just use weewx to make generating the input data a bit easier.

That said, if what you have already works fine, you're done :-)

Remy LAVABRE

unread,
Jun 7, 2021, 1:31:28 PM6/7/21
to weewx...@googlegroups.com
Hello Rob.
Multi_alarm.py is perfect for the job !
And the battery will be checked at each loop packet record !
After, you can sens à mail or SMS or... all what you want !
;-)


--
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/633505d8-0882-40c0-9bc9-7e8f7118cac7n%40googlegroups.com.

Rob Cranfill

unread,
Jun 8, 2021, 11:48:16 AM6/8/21
to weewx-user
Thanks, Remy, I will check that out!
 - rob

Rob Cranfill

unread,
Jun 8, 2021, 11:49:28 AM6/8/21
to weewx-user
Thanks, Vince, I will check out using a .tmpl file to create a text file, perhaps.
 - rob

Rob Cranfill

unread,
Jun 8, 2021, 12:13:06 PM6/8/21
to weewx-user
Remy, I am sorry if I am missing the obvious - where do I find Multi_alarm.py? 

On Monday, June 7, 2021 at 10:31:28 AM UTC-7 remy.l...@gmail.com wrote:

Remy LAVABRE

unread,
Jun 8, 2021, 12:34:14 PM6/8/21
to weewx...@googlegroups.com
Multi_alarm.py is a super python program for different test alarm on each loop pack et {ex outTemp<0, rainRate>0, inTemp<17 etc. etc}.
If you want only battery power test, perhaps this is more for you... :

If you want I can send you multi alarm.py but i made little change in the code to have a different delay between 2 alarms for each type of alert {ex 36000 seconds for inTemp<17 but 3600 seconds for rainRate>1 etc. Etc}
In the original you specify a delay in weewx.conf and the delay is the same for each alarm you program




Rob Cranfill

unread,
Jun 9, 2021, 11:52:50 PM6/9/21
to weewx-user
Thanks to all who suggested various solutions or approaches. I perhaps was overly-specific in the original question, saying I wanted to run a script, when all along the solution was under my nose: there is an example provided in the standard distro that does, I think, just what I want - /usr/share/doc/weewx/examples/lowBattery.py

I will dink around with that and report back here if I find anything significant.

Thanks again, 
  rob
Reply all
Reply to author
Forward
0 new messages