Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: fromhex() argument 1 must be string or read-only buffer, not None #16

Open
siglun88 opened this issue Nov 25, 2019 · 0 comments

Comments

@siglun88
Copy link

siglun88 commented Nov 25, 2019

Got the following error when trying to read the device:

Traceback (most recent call last):
  File "read_waveplus.py", line 222, in <module>
    waveplus.connect()
  File "read_waveplus.py", line 124, in connect
    SN = parseSerialNumber(ManuData)
  File "read_waveplus.py", line 87, in parseSerialNumber
    ManuData = bytearray.fromhex(ManuDataHexStr)
TypeError: fromhex() argument 1 must be string or read-only buffer, not None

In the connect method defined on line 113 it turns out that dev.getValueText(255) returns None at some point in the for loop.

Quick Fix:

Rewrite the for-loop with an if-statement to check if the value of ManuData is None. And if that is the case, continue the for-loop without calling parseSerialNumber.

On line 121, change the for-loop to this:

for dev in devices:
                    ManuData = dev.getValueText(255)
                    if (ManuData is None):
                        continue
                    SN = parseSerialNumber(ManuData)
                    if (SN == self.SN):
                        self.MacAddr = dev.addr  # exits the while loop on next conditional check
                        break  # exit for loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant