Skip to content

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

@erikjber

Description

@erikjber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions