Fixing the pyit600 errors on connection and improving the gateway json response#42
Open
samuellazea wants to merge 5 commits into
Open
Fixing the pyit600 errors on connection and improving the gateway json response#42samuellazea wants to merge 5 commits into
samuellazea wants to merge 5 commits into
Conversation
Fix error on connect to the gateway
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before the fixes
`root@32f54c65cdfe:/app/pyit600# python main.py --host 192.168.150.255 --euid xxxxxx --debug
DEBUG:pyit600:Trying to connect to gateway at 192.168.150.255
DEBUG:pyit600:Gateway request: POST http://192.168.150.255:80/deviceid/read
{"requestAttr": "readall"}
--- Logging error ---
Traceback (most recent call last):
File "/app/pyit600/pyit600/gateway.py", line 922, in _make_encrypted_request
with async_timeout.timeout(self._request_timeout):
AttributeError: enter
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/logging/init.py", line 1100, in emit
msg = self.format(record)
File "/usr/local/lib/python3.10/logging/init.py", line 943, in format
return fmt.format(record)
File "/usr/local/lib/python3.10/logging/init.py", line 678, in format
record.message = record.getMessage()
File "/usr/local/lib/python3.10/logging/init.py", line 368, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "/app/pyit600/main.py", line 172, in
asyncio.run(main())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
self._run_once()
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1909, in _run_once
handle._run()
File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/app/pyit600/main.py", line 72, in main
await gateway.connect()
File "/app/pyit600/pyit600/gateway.py", line 101, in connect
all_devices = await self._make_encrypted_request(
File "/app/pyit600/pyit600/gateway.py", line 956, in _make_encrypted_request
_LOGGER.error("Exception. %s / %s", type(e), repr(e.args), e)
Message: 'Exception. %s / %s'
Arguments: (<class 'AttributeError'>, "('enter',)", AttributeError('enter'))
Traceback (most recent call last):
File "/app/pyit600/pyit600/gateway.py", line 922, in _make_encrypted_request
with async_timeout.timeout(self._request_timeout):
AttributeError: enter
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/pyit600/main.py", line 172, in
asyncio.run(main())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/app/pyit600/main.py", line 72, in main
await gateway.connect()
File "/app/pyit600/pyit600/gateway.py", line 101, in connect
all_devices = await self._make_encrypted_request(
File "/app/pyit600/pyit600/gateway.py", line 957, in _make_encrypted_request
raise IT600CommandError(
pyit600.exceptions.IT600CommandError: Unknown error occurred while communicating with iT600 gateway
`
After the fixes
`root@32f54c65cdfe:/app/pyit600# python main.py --host 192.168.150.185 --euid xxxxxxx--debug
DEBUG:pyit600:Trying to connect to gateway at 192.168.150.255
DEBUG:pyit600:Gateway request: POST http://192.168.150.255:80/deviceid/read
{"requestAttr": "readall"}
DEBUG:pyit600:Gateway response:
{"id":[{"data":{"DeviceType":100,"Endpoint":1,"UniID":"xxx"},"sGenSche":{"UpdateGenScheStatus":0},"DeviceL":{"DeviceType":100,"getModelIdentifierFlag_i":1,"DeviceSubType":1026,"UnquieID":"xxxx","ClusterIDList_i":"xxxx#","AttributeList":"xxxx"
..............`
Please let me know if you see something that should be also changed/improved