iMicknl / python-overkiz-api

Async Python wrapper to interact with internal Somfy TaHoma API, or other OverKiz API's.
MIT License
46 stars 29 forks source link

get_local_tokens (local) - Error expecting expiration_time #1229

Closed Eridani78 closed 1 day ago

Eridani78 commented 4 months ago

Hi Mickael,

I am triying to use the get_local_tokens command of your API but I receive the following error:

TypeError: LocalToken.__init__() missing 1 required keyword-only argument: 'expiration_time'

as it seems that the overkiz server does not include the "expiration_time" parameter in its response for the Get available tokens request.

Any suggestion ?

Gateway is Tahoma V2

Eridani78 commented 3 months ago

Hello Mick,

Any updates regarding my two requests ?

Thanks in advance

iMicknl commented 3 months ago

Can you share a code snippet so that I can try to reproduce this?

ArjanM83 commented 2 months ago

Hi @iMicknl, this is a code snippet to reproduce the error. I'm facing this issue with my Somfy TaHoma Switch:

import asyncio

from pyoverkiz.client import OverkizClient
from pyoverkiz.const import SUPPORTED_SERVERS

USERNAME = "XXX"
PASSWORD = "XXX"
LOCAL_GATEWAY = "XXX.XXX.XXX.XXX"
VERIFY_SSL = False

async def main() -> None:
    async with OverkizClient(
        username=USERNAME, password=PASSWORD, server=SUPPORTED_SERVERS["somfy_europe"]
    ) as client:

        await client.login()
        gateways = await client.get_gateways()
        for gateway in gateways:
            print(await client.get_local_tokens(gateway_id=gateway.id))

asyncio.run(main())

Result:


  File "get_local_tokens_issue.py", line 23, in <module>
    asyncio.run(main())
  File "C:\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "get_local_tokens_issue.py", line 21, in main
    print(await client.get_local_tokens(gateway_id=gateway.id))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python311\Lib\site-packages\backoff\_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python311\Lib\site-packages\pyoverkiz\client.py", line 786, in get_local_tokens
    local_tokens = [LocalToken(**lt) for lt in humps.decamelize(response)]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python311\Lib\site-packages\pyoverkiz\client.py", line 786, in <listcomp>
    local_tokens = [LocalToken(**lt) for lt in humps.decamelize(response)]
                    ^^^^^^^^^^^^^^^^
TypeError: LocalToken.__init__() missing 1 required keyword-only argument: 'expiration_time'```