ultimeter driver

121 views
Skip to first unread message

Chris Thompstone

unread,
Apr 9, 2021, 9:56:42 AM4/9/21
to weewx-user
Hi Guys,
I have been trying to upgrade to version 4 since my Pi decided to throw a strop.
Anyway, it's been fairly hardwork.

I have this message continuous in the logs:
DEBUG weewx.drivers.ultimeter: Decode failed for '----': invalid literal for int() with base 16: '----'
just coming every 1s or so.

I also have some other issue which I can't seem to find:
ERROR weewx.cheetahgenerator: Generate failed with exception '<class 'TypeError'>'
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: **** Ignoring template /home/weewx/skins/Standard/index.html.tmpl
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: **** Reason: '>' not supported between instances of 'NoneType' and 'float'
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: ****    File "/home/weewx/bin/weewx/cheetahgenerator.py", line 326, in generate
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: ****    File "_home_weewx_skins_Standard_index_html_tmpl.py", line 1378, in respond
Apr  9 14:45:16 weewx weewx[868] ERROR weewx.cheetahgenerator: ****  TypeError: '>' not supported between instances of 'NoneType' and 'float'

My wind vein has blown off the roof, so wind direction and speed are probably both None.
Whether this is something to do with it I don't know, but I can't get the index template generated.
Thanks
Chris

p q

unread,
Apr 9, 2021, 10:20:41 AM4/9/21
to weewx...@googlegroups.com
Looks like you switched to Python 3 from Python 2.7 and the driver isn't compatible, based on the error message.

--
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/dd2cd2fd-515b-47b3-a8c5-cb1692508eb8n%40googlegroups.com.


--
Peter Quinn
(415)794-2264

Chris Thompstone

unread,
Apr 9, 2021, 10:26:22 AM4/9/21
to weewx-user
Oh, the ultimeter isn't supported on Python 3 and ver 4 weewx ?
Is that what your saying?
Oh, had not planned on that.
I found some sort of error in my template, which I've kind of resolved.
But the Ultimeter driver... not sure on this one.
Thanks
Chris

Tom Keffer

unread,
Apr 9, 2021, 11:03:24 AM4/9/21
to weewx-user
The driver should work fine with Python 3.

However, the driver has a small, non-functional bug that causes it to emit that error message when it encounters a "dash" value. It's non-functional because it emits the right value ("None"). It just shouldn't log an error. 

Try this version. I've taken the occasion of having a real, live Ultimeter user to also fix some ambiguities around byte array types. Let me know if it works.

-tk

ultimeter.py

Chris Thompstone

unread,
Apr 9, 2021, 11:18:14 AM4/9/21
to weewx-user

just tried that and get:
Apr  9 16:17:18 weewx weewx[1719] DEBUG weewx.drivers.ultimeter: Close serial port /dev/ttyUSB0
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__: Caught unrecoverable exception:
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  startswith first arg must be bytes or a tuple of bytes, not str
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  Traceback (most recent call last):
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/drivers/ultimeter.py", line 346, in _decode
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****      v = int(s, 16)
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  ValueError: invalid literal for int() with base 16: b'----'
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  During handling of the above exception, another exception occurred:
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  Traceback (most recent call last):
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****    File "/home/weewx/bin/weewxd", line 157, in main
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****      engine.run()
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 208, in run
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****      for packet in self.console.genLoopPackets():
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/drivers/ultimeter.py", line 132, in genLoopPackets
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****      data = Station.parse_readings(readings)
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/drivers/ultimeter.py", line 317, in parse_readings
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****      data['inHumidity'] = Station._decode(buf[28:32], 0.1)  # percent
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/drivers/ultimeter.py", line 354, in _decode
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****      if not s. startswith('--'):
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  TypeError: startswith first arg must be bytes or a tuple of bytes, not str
Apr  9 16:17:19 weewx weewx[1719] CRITICAL __main__:     ****  Exiting.

Tom Keffer

unread,
Apr 9, 2021, 11:36:35 AM4/9/21
to weewx...@googlegroups.com
Sorry. I’ll try to get an update out later today.

--
-tk

Chris Thompstone

unread,
Apr 9, 2021, 11:50:32 AM4/9/21
to weewx-user
Don't worry, I think I may have patched it.  I'm not really much of a coder (although can do some stuff)...
Modded your file.  see line 345 onwards.
See attached

ultimeter.py

Tom Keffer

unread,
Apr 9, 2021, 6:05:13 PM4/9/21
to weewx-user
You had the right idea, but we have to be careful about values that are encoded in only two bytes.

Try this version.

-tk

ultimeter.py

p q

unread,
Apr 9, 2021, 6:35:01 PM4/9/21
to weewx...@googlegroups.com
Sorry for the wrong answer!



--
Peter Quinn
(415)794-2264

Chris Thompstone

unread,
Apr 10, 2021, 3:35:17 AM4/10/21
to weewx-user
Sorry it doesn't like that one:
Apr 10 08:32:33 weewx weewx[5327] DEBUG weewx.drivers.ultimeter: Decode failed for 'b'----'': invalid literal for int() with base 16: b'----'
it prefers mine, lol
Chris

Chris Thompstone

unread,
Apr 10, 2021, 3:51:23 AM4/10/21
to weewx-user
Also why when ftp happens 1 of the files gives this:
Uploaded file /var/www/daybarometer.png to /daybarometer.png
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine: ftpgenerator: (2): caught exception '<class 'ftplib.error_perm'>': 553 Prohibited directory name
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****  Traceback (most recent call last):
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 331, in run
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      n = ftp_data.run()
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weeutil/ftpupload.py", line 154, in run
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      _make_remote_dir(ftp_server, remote_dir_path)
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/home/weewx/bin/weeutil/ftpupload.py", line 269, in _make_remote_dir
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      ftp_server.mkd(remote_dir_path)
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/usr/lib/python3.7/ftplib.py", line 643, in mkd
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      resp = self.voidcmd('MKD ' + dirname)
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/usr/lib/python3.7/ftplib.py", line 278, in voidcmd
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      return self.voidresp()
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/usr/lib/python3.7/ftplib.py", line 251, in voidresp
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      resp = self.getresp()
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****    File "/usr/lib/python3.7/ftplib.py", line 246, in getresp
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****      raise error_perm(resp)
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine:         ****  ftplib.error_perm: 553 Prohibited directory name
Apr 10 08:45:37 weewx weewx[5576] ERROR weewx.reportengine: ftpgenerator: Upload failed

the file seems to be on the ftp server (I tried deleting everything on the ftp to see if it uploads it)
only happens for this 1 file.
I notice that all my files in /var/www that upload are set with root permissions, does that have anything to do with it?
Not sure how to make weewx change set these to www-data permissions

Chris Thompstone

unread,
Apr 10, 2021, 4:35:26 AM4/10/21
to weewx-user
So I manually deleted all the files from the remote ftp server to make it upload a fresh.
it tries to ftp ALL files twice, but fails on the first NOAA txt file, the partial file from 2014-10 when station started up.
because this fails (although I can see it on the ftp server), it tries a 2nd time to upload everything, then quits on this file again.
the whole process takes 3 minutes to upload as it tries to upload everything (twice on every 5min cycle) because that 1 file fails.
any ideas on a fix for this?

Tom Keffer

unread,
Apr 10, 2021, 7:48:20 AM4/10/21
to weewx-user
Too many years using Python 2, not enough on Python 3. Try this version of ultimeter.py. 

ultimeter.py

Chris Thompstone

unread,
Apr 10, 2021, 8:21:49 AM4/10/21
to weewx-user
Thanks, driver seems good, (no complains at the logger anyway)
Reply all
Reply to author
Forward
0 new messages