You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 ofapi.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.
The text was updated successfully, but these errors were encountered: