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

Listing devices fails after upgrade from 0.7.8 to 1.2.0, even after changing api syntax. #158

Open
erikjber opened this issue Feb 26, 2025 · 0 comments

Comments

@erikjber
Copy link

erikjber commented Feb 26, 2025

I have a simple test application with this code:

import asyncio, aiohttp, pysmartthings
async def main():
async with aiohttp.ClientSession() as session:
api = pysmartthings.SmartThings(session, <my token>)
devices = await api.get_devices()
for num,dev in enumerate(devices):
print(f"Device {num}: {dev.label} {dev.name} {dev.room_id} {dev.capabilities}")

if __name__ == "__main__":
asyncio.run(main())

Desired outcome:
I get a list of all my devices.

Actual outcome:
The app crashes with this output:
File "/home/erikjber/workspace/appdaemon/misc/smart_things_tester.py", line 6, in main devices = await api.get_devices() ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/erikjber/.local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 196, in get_devices resp = await self._get("devices", params=params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/erikjber/.local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 132, in _get return await self._request(METH_GET, uri, params=params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/erikjber/.local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 107, in _request async with asyncio.timeout(self.request_timeout): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/asyncio/timeouts.py", line 146, in timeout return Timeout(loop.time() + delay if delay is not None else None) ~~~~~~~~~~~~^~~~~~~ TypeError: unsupported operand type(s) for +: 'float' and 'ClientSession' Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x76914bd77200>

This worked perfectly on version 0.7.8 (only difference was that I used api.devices() instead of api.get_devices().

What I have tried to fix the problem:
I have tried to find examples or tutorials, but they are all targeted at the old version, not the current one.
Upgrading asyncio and aiohttp to the latest versions (3.4.3 and 3.11.11 respectively) does not help.

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