How to setup the Low Battery Alarm

104 views
Skip to first unread message

Francis

unread,
Apr 7, 2026, 10:06:36 AMApr 7
to weewx-user
I cannot believe I am having so much trouble setting up the lowBattery.py with alarm.py so I get an email when a battery is low!
I have searched this forum and the internet, but I cannot find instructions on exactly how to set this up.
I have been using weewx for many years. I have been using Linux for probably 25 years. I have LOTS of Raspberry Pis of all sorts checking this and that, I also program in Python a good bit.
I have a Davis Vantage Pro 2 with a Pi4 running weewx version 5.2.0-1 installed using the package manager.
I have the Wind Sensor on Station 3 and the ISS on Station 2.
Reading the alarm.py and lowBattery.py files I thought I had to put these files into this folder: /usr/share/weewx/user
This did not work with error: ModuleNotFoundError: No module named 'user.lowBattery'
I reported this on the GitHub page as an issue when I should have reported here. I was not aware there was a group here. 
It was suggested I put the user folder in the same folder as the weewx.conf file which I have done.
I added this  report_services = weewx.engine.StdPrint, weewx.engine.StdReport, user.lowBattery.BatteryAlarm to the [Engine] section of the config file.
My alarm.py is the same as the example in the lowBattery.py file but obvoiusly I have changed the mailing info to suit my network.
I still get the error when I start weewx. Please see the attached file
Clearly I am not understanding where to place the two files in a system which used the Package Manager to install weewx.
Also what battery-flags should I include and where?
Also what value should I use to trigger the alarm?
weewx_error.txt

Tom Keffer

unread,
Apr 7, 2026, 10:25:01 AMApr 7
to weewx...@googlegroups.com
With V5.0, the user folder has moved from /usr/share/weewx/user to /etc/weewx/bin/user. Note the 'bin' in the path. See the Upgrade Guide section New location for user directory

--
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 visit https://groups.google.com/d/msgid/weewx-user/ede6de1a-e213-49f2-938b-0d5b0cde9d94n%40googlegroups.com.

Francis

unread,
Apr 13, 2026, 3:27:19 AMApr 13
to weewx-user
OK, for anyone out there who is struggling with this, I have AT LAST got it working!
I think the documentation could be more helpful.
I have put the alarm.py and the lowBattery.py in the correct location now at /etc/weewx/bin/user
I have added the following to the weewx.conf file line beginning report_services in the [Engine] section:
report_services = weewx.engine.StdPrint, weewx.engine.StdReport, user.lowBattery.BatteryAlarm, user.alarm.MyAlarm
I have added the [Alarm] section like this with the alarm to be triggered at the top:
[Alarm]
    expression = "txBatteryStatus != 0"
    time_wait = 3600
    count_threshold = 10
    smtp_host = mail.mynet.net
    smtp_user = francis
    smtp_password = mypasswd
    from = fra...@mynet.net
    mailto = fra...@mynet.net
    subject = "Time to change one of the station batteries!"

It is setup according to the log, and I set the alarm ==0 so I could test getting an alarm, and I do get a message. 
As I understand it, any state that is non zero indicates a low battery.
There are several battery alarms:
'txBatteryStatus', 'windBatteryStatus', 'rainBatteryStatus', 'inTempBatteryStatus', 'outTempBatteryStatus'
Only the txBatteryStatus works as far as I can see
Hope this helps anyone like me who has a problem setting this up. It is easy once you know how....
Reply all
Reply to author
Forward
0 new messages