alarm.py causing weewx 4 to stop

53 views
Skip to first unread message

Ian Prescott

unread,
May 10, 2020, 12:38:29 AM5/10/20
to weewx-user
Hi I have a fineoffset usb weather station which has been running raspbian stretch and weewx 3.9 ok and using alarm.py with no issues.
For weewx 4 I decided to start from fresh, new sd card, new raspbian buster, and a fresh weewx install.
After a of couple learner hicups I now have weewx 4 using buster and python 3 up and running.
However I have hit a wall with alarm.py
If I use expression = "rain > 0.0" then weewx crashes.
If I use expression = "outTemp < 30.0" then weewx keeps running but no email is ever received.

So after a search of the forum I found this command
sudo PYTHONPATH=/usr/share/weewx python3 /usr/share/weewx/user/alarm.py /etc/weewx/weewx.conf
This ran ok and I got an email

I have attached my weewx.conf and the log from when I start weewx to when it crashes using expression = "rain > 0.0".
I have no idea how to get any useful info regarding expression = "outTemp < 30.0", there doesn't appear to be anything unusual in the log.

Thanks

and again a fantastic program and a great learning experience.
alarm.py.error.txt
weewx.conf-10-5-20

Tom Keffer

unread,
May 10, 2020, 7:29:14 AM5/10/20
to weewx-user
I suspect 'rain' occasionally has the value 'None', which cannot be compared to zero. Try this expression instead

expression = 'rain is not None and rain > 0.0'

-tk


--
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/ca5c79a5-c6bc-40d3-b0a0-1915d2929135%40googlegroups.com.

Greg from Oz

unread,
May 10, 2020, 7:51:58 AM5/10/20
to weewx-user
Hi tom,

In the alarm.py how would I put the None check in the code rather than make the expression have the check code.

I think it's on this line:
if eval(self.expression, None, record):                       # NOTE 3

Would it be:
if record is not None and eval(self.expression, None, record):                       # NOTE 3

I am not a python programmer by the way. That way if any expression that could be none would be covered. IE you could put in rain > 0.0

Thanks


On Sunday, 10 May 2020 21:29:14 UTC+10, Tom Keffer wrote:
I suspect 'rain' occasionally has the value 'None', which cannot be compared to zero. Try this expression instead

expression = 'rain is not None and rain > 0.0'

-tk


On Sat, May 9, 2020 at 9:38 PM Ian Prescott <ianpre...@gmail.com> wrote:
Hi I have a fineoffset usb weather station which has been running raspbian stretch and weewx 3.9 ok and using alarm.py with no issues.
For weewx 4 I decided to start from fresh, new sd card, new raspbian buster, and a fresh weewx install.
After a of couple learner hicups I now have weewx 4 using buster and python 3 up and running.
However I have hit a wall with alarm.py
If I use expression = "rain > 0.0" then weewx crashes.
If I use expression = "outTemp < 30.0" then weewx keeps running but no email is ever received.

So after a search of the forum I found this command
sudo PYTHONPATH=/usr/share/weewx python3 /usr/share/weewx/user/alarm.py /etc/weewx/weewx.conf
This ran ok and I got an email

I have attached my weewx.conf and the log from when I start weewx to when it crashes using expression = "rain > 0.0".
I have no idea how to get any useful info regarding expression = "outTemp < 30.0", there doesn't appear to be anything unusual in the log.

Thanks

and again a fantastic program and a great learning experience.

--
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...@googlegroups.com.

Ian Prescott

unread,
May 10, 2020, 8:08:10 AM5/10/20
to weewx-user
Thanks Tom
I made the change then stopped/started weewx and it is still going.
regards Ian 

On Sunday, 10 May 2020 21:29:14 UTC+10, Tom Keffer wrote:
I suspect 'rain' occasionally has the value 'None', which cannot be compared to zero. Try this expression instead

expression = 'rain is not None and rain > 0.0'

-tk


On Sat, May 9, 2020 at 9:38 PM Ian Prescott <ianpre...@gmail.com> wrote:
Hi I have a fineoffset usb weather station which has been running raspbian stretch and weewx 3.9 ok and using alarm.py with no issues.
For weewx 4 I decided to start from fresh, new sd card, new raspbian buster, and a fresh weewx install.
After a of couple learner hicups I now have weewx 4 using buster and python 3 up and running.
However I have hit a wall with alarm.py
If I use expression = "rain > 0.0" then weewx crashes.
If I use expression = "outTemp < 30.0" then weewx keeps running but no email is ever received.

So after a search of the forum I found this command
sudo PYTHONPATH=/usr/share/weewx python3 /usr/share/weewx/user/alarm.py /etc/weewx/weewx.conf
This ran ok and I got an email

I have attached my weewx.conf and the log from when I start weewx to when it crashes using expression = "rain > 0.0".
I have no idea how to get any useful info regarding expression = "outTemp < 30.0", there doesn't appear to be anything unusual in the log.

Thanks

and again a fantastic program and a great learning experience.

--
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...@googlegroups.com.

Tom Keffer

unread,
May 10, 2020, 8:13:48 AM5/10/20
to weewx-user
The problem here is not that the entire record is None (which should never happen), but that a value inside the record is None. 

There are two choices:
1. Explicitly check for None. This is the preferred solution.
2. Alternatively, the code could be changed to catch the exception, optionally log it, then ignore the exception. Problem with this solution is that it can cover a lot of sins.

-tk

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/bdb0aa99-c00e-4f2f-aa27-0651a3bb21eb%40googlegroups.com.

Greg from Oz

unread,
May 10, 2020, 8:21:39 AM5/10/20
to weewx-user
Ok so it's not easy.

Maybe I should learn python :)

Thanks
Greg

Tom Keffer

unread,
May 10, 2020, 8:31:46 AM5/10/20
to weewx-user
These days, Python and Javascript are by far the two most useful languages.

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/1f1c840f-5f5a-4506-85e2-e98b2d77d949%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages