Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
log more data on unexpected receive messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mjmeli committed Nov 1, 2021
1 parent 1e222ca commit d5e1003
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyduke-energy
version = 0.0.10
version = 0.0.11
author = Michael Meli
author_email = [email protected]
description = Python Wrapper for unofficial Duke Energy REST API
Expand Down
9 changes: 8 additions & 1 deletion src/pyduke_energy/realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,14 @@ def _on_msg(self, _client: mqtt.Client, _userdata, msg):
This is a class with members topic, payload, qos, retain
"""
if not self.rx_msg:
_LOGGER.warning("Unexpected message: %s", msg)
msg_if_decoded = None
try:
msg_if_decoded = msg.payload.decode("utf8")
except Exception as ex:
msg_if_decoded = f"Could not decode message: {ex}"
_LOGGER.warning(
"Unexpected message: %s (decoded = %s)", msg, msg_if_decoded
)
else:
self.rx_msg.set_result((msg.payload.decode("utf8")))
self.on_msg(msg)
Expand Down

0 comments on commit d5e1003

Please sign in to comment.