5.2 breaks Meteostick support

75 views
Skip to first unread message

Joe Garcia

unread,
Oct 18, 2025, 10:02:09 AM (4 days ago) Oct 18
to weewx-user
Another instance of 5.2 breakage, Meteostick support no longer works:

CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", l>
CRITICAL __main__:     ****      crc_result = crc16(msg)
CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", lin>
CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: (_table>
CRITICAL __main__:     ****                    byte_buf, crc_start)
CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", lin>
CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: (_table>
CRITICAL __main__:     ****                                               >
CRITICAL __main__:     ****  TypeError: unsupported operand type(s) for ^:>
CRITICAL __main__:     ****  Exiting.

This may also have come about from an update to Python that occurred at the same time, not 5.2-specific.  Unfortunately I don't speak Python so I'm not sure what's required to fix meteostick.py, and the original on Github hasn't been updated since 2019.

Tom Keffer

unread,
Oct 18, 2025, 10:12:18 AM (4 days ago) Oct 18
to weewx...@googlegroups.com
I'm sorry but the lines in your snippet are so truncated it's hard to tell what's going on. Can we see the full lines?

--
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/56358b16-66c3-41f6-b500-5cd3e6f9aad6n%40googlegroups.com.

Joe Garcia

unread,
Oct 19, 2025, 9:16:23 AM (3 days ago) Oct 19
to weewx-user
Yeah, sorry, the post took awhile to appear so I couldn't update it with the full log, whole thing is attached below.  Looking at the repo, there was a change to crc16.py 11 months ago that may have caused this:

- def crc16(bytes, crc_start=0):
+ def crc16(byte_buf, crc_start=0): 

- return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff, byte_buf, crc_start)
+ crc_sum = reduce(lambda crc, ch : (_table[(crc >> 8) ^ ch] ^ (crc << 8)) & 0xffff, byte_iter, crc_start)

but see my earlier comment about no hablo Python :).

CRITICAL __main__: Caught unrecoverable exception:
CRITICAL __main__:     ****  unsupported operand type(s) for ^: 'int' and 'str'
CRITICAL __main__:     ****  Traceback (most recent call last):
CRITICAL __main__:     ****    File "/usr/share/weewx/weewxd.py", line 127, in main
CRITICAL __main__:     ****      engine.run()
CRITICAL __main__:     ****      ~~~~~~~~~~^^
CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/engine.py", line 204, in run
CRITICAL __main__:     ****      for packet in self.console.genLoopPackets():
CRITICAL __main__:     ****                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", line 311, in genLoopPackets
CRITICAL __main__:     ****      data = self.station.parse_readings(readings, self.rain_per_tip)
CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", line 638, in parse_readings
CRITICAL __main__:     ****      data = self.parse_raw(raw,
CRITICAL __main__:     ****                            self.channels['iss'],
CRITICAL __main__:     ****      ...<3 lines>...
CRITICAL __main__:     ****                            self.channels['temp_hum_2'],
CRITICAL __main__:     ****                            rain_per_tip)
CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", line 687, in parse_raw
CRITICAL __main__:     ****      Meteostick._check_crc(raw_msg_crc, chksum)
CRITICAL __main__:     ****      ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
CRITICAL __main__:     ****    File "/etc/weewx/bin/user/meteostick.py", line 505, in _check_crc

CRITICAL __main__:     ****      crc_result = crc16(msg)
CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", line 49, in crc16
CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff,

CRITICAL __main__:     ****                    byte_buf, crc_start)
CRITICAL __main__:     ****    File "/usr/share/weewx/weewx/crc16.py", line 49, in <lambda>
CRITICAL __main__:     ****      return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff,
CRITICAL __main__:     ****                            ~~~~~~~~~~~~~~~^~~~
CRITICAL __main__:     ****  TypeError: unsupported operand type(s) for ^: 'int' and 'str'
CRITICAL __main__:     ****  Exiting.
Traceback (most recent call last):
  File "/usr/share/weewx/weewxd.py", line 226, in <module>
    main()
    ~~~~^^
  File "/usr/share/weewx/weewxd.py", line 127, in main
    engine.run()
    ~~~~~~~~~~^^
  File "/usr/share/weewx/weewx/engine.py", line 204, in run
    for packet in self.console.genLoopPackets():
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/etc/weewx/bin/user/meteostick.py", line 311, in genLoopPackets
    data = self.station.parse_readings(readings, self.rain_per_tip)
  File "/etc/weewx/bin/user/meteostick.py", line 638, in parse_readings
    data = self.parse_raw(raw,
                          self.channels['iss'],
    ...<3 lines>...
                          self.channels['temp_hum_2'],
                          rain_per_tip)
  File "/etc/weewx/bin/user/meteostick.py", line 687, in parse_raw
    Meteostick._check_crc(raw_msg_crc, chksum)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/etc/weewx/bin/user/meteostick.py", line 505, in _check_crc
    crc_result = crc16(msg)
  File "/usr/share/weewx/weewx/crc16.py", line 49, in crc16
    return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff,
                  byte_buf, crc_start)
  File "/usr/share/weewx/weewx/crc16.py", line 49, in <lambda>
    return reduce(lambda crc_sum, ch: (_table[(crc_sum >> 8) ^ ch] ^ (crc_sum << 8)) & 0xffff,
                                              ~~~~~~~~~~~~~~~^~~~
TypeError: unsupported operand type(s) for ^: 'int' and 'str'

Tom Keffer

unread,
Oct 19, 2025, 9:38:09 AM (3 days ago) Oct 19
to weewx...@googlegroups.com
It appears that this part of the meteostick driver was never updated to Python 3. 

The crc16() function could work with either Python 2 or 3 until V5.2, at which point the Python 2 code was removed.

For the moment, replace the file /usr/share/weewx/weewx/crc16.py with the older version, attached below.

I'll file an issue with the author.

-tk

crc16.py

Joe Garcia

unread,
Oct 19, 2025, 11:42:50 PM (3 days ago) Oct 19
to weewx-user
Thanks, I'll give it a go and report back.

If by "the author" you mean the developer of the Meteostick driver, I'm not sure how useful that'll be, a lot of his (very useful) WeeWX-related tools date from around the 2020 time frame and haven't been updated since then.  For example there's multi-year-old PRs for the driver still active.  Not meant as a criticism, everyone has a day job they need to deal with, just pointing out that a fix at the meteostick.py end may be awhile forthcoming.

Joe Garcia

unread,
Oct 20, 2025, 12:07:25 AM (3 days ago) Oct 20
to weewx-user
OK, that fixed it, thanks!  For anyone else running into this problem, just replace /usr/share/weewx/weewx/crc16.py with @Tom Keffer's earlier version.
Reply all
Reply to author
Forward
0 new messages