Andre0512 / Andre0512/speedport-api

raise ConnectionError() - Speedport3

Aberta
#3 1 comentário 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
33
Forks
13
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Hey Andre,

I stumbled accross your api and I loved it. It basically does everything I want to do, BUT I have a Speedport 3 in place. Whenever I try to run your code it raises a connection error as seen below:

```
Traceback (most recent call last):
File "/Users/USERNAME/Library/CloudStorage/OneDrive-TUI/Skripte/Python Skripte/network.py", line 23, in
devices = asyncio.run(Speedport().devices)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/site-packages/speedport/speedport.py", line 81, in devices
data = await self.api.get_devices()
^^^^^^^^
File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/site-packages/speedport/speedport.py", line 77, in api
raise ConnectionError()
```

Here is why I find this really interesting. When I try to connect to the router via script a (synchronously) the script says
```
Login successful!
/Users/USERNAME/Library/CloudStorage/OneDrive-TUI/Skripte/Python Skripte/network.py:16: RuntimeWarning: coroutine 'Speedport.login' was never awaited
```

in script b (asynchronously) I receive the already posted connection error. Is there more to it that I don't see or is it "just" because of the speedport 3? I have to admit network stuff (specifically web and javascript) are not my strongsuit.

script a
```
from speedport import Speedport

def login_to_router(url, password):
speedport = Speedport(url)

# Login to the router
login_status = speedport.login(password)

if login_status:
print("Login successful!")
else:
print("Login failed!")

url = 'http://192.168.2.1'
password = 'PASSWORD'
login_to_router(url, password)
```

script b
```
from speedport import Speedport
import asyncio

async def login_to_router(url, password):
try:
speedport = Speedport(url)

# Try to login to the router
login_status = await speedport.login(password)

if login_status:
print("Login successful!")
else:
print("Login failed!")
except Exception as e:
print(f"Failed to connect to the router. Error: {e}")

url = 'http://192.168.2.1' # replace with your router's URL
password = 'PASSWORD' # replace with your password
asyncio.run(login_to_router(url, password))
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.