Skip to content

Better debug for command exception - #60

Open
FrugalGuy wants to merge 2 commits into
ziirish:masterfrom
FrugalGuy:betterDebug
Open

Better debug for command exception#60
FrugalGuy wants to merge 2 commits into
ziirish:masterfrom
FrugalGuy:betterDebug

Conversation

@FrugalGuy

Copy link
Copy Markdown

I am noticing that my smart plug isn't working here, but works find in Home Assistant and in the Smart Life app.
The plug generates this pretty scant debug output:

[2023-12-24 00:38:45,445] DEBUG: Checking status of Printer Power.
[2023-12-24 00:38:45,446] DEBUG: Sending command: info to Printer Power
[2023-12-24 00:38:45,530] DEBUG: Something went wrong while running the command ord() expected a character, but string of length 0 found

With the updated code, you see this instead, which is somewhat better, I think, because you can see where the issue arose:

[2023-12-24 00:40:22,337] DEBUG: Checking status of Printer Power.
[2023-12-24 00:40:22,339] DEBUG: Sending command: info to Printer Power
[2023-12-24 00:40:22,596] DEBUG: Something went wrong while running the command ord() expected a character, but string of length 0 found
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_tuyasmartplug/__init__.py", line 295, in sendCommand
    func()
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_tuyasmartplug/utils/pytuya.py", line 343, in status
    result = cipher.decrypt(result, False)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_tuyasmartplug/utils/pytuya.py", line 91, in decrypt
    return self._unpad(raw).decode("utf-8")
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_tuyasmartplug/utils/pytuya.py", line 107, in _unpad
    return s[: -ord(s[len(s) - 1 :])]
TypeError: ord() expected a character, but string of length 0 found

BTW, clearing the 3.3 protocol box eliminates the exception, but doesn't get the plug to work.

I notice that my plug is using 3.4 protocol, which looks like it's not supported, yet. I can't tell if the plug should work without the 3.3 box checked.

That's another issue, though. :-)

add traceback to debug for command exception
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

Successfully merging this pull request may close these issues.

1 participant