JoDehli / PyLoxone

Python Loxone binding
Apache License 2.0
184 stars 41 forks source link

Error setting up entry PyLoxone for loxone #114

Closed AHub88 closed 2 years ago

AHub88 commented 2 years ago

Hi,

I have followed the instructions, but unfortunately fail at the last point.

When I try to connect PyLoxone with Loxone, I get an error message.

"Error setting up entry PyLoxone for loxone".

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant.config_entries
Source: custom_components/loxone/api.py:121
Integration: PyLoxone (documentation, issues)
First occurred: 08:58:57 (2 occurrences)
Last logged: 09:05:05

Error setting up entry PyLoxone for loxone
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/anyio/_core/_sockets.py", line 149, in connect_tcp
    addr_obj = ip_address(remote_host)
  File "/usr/local/lib/python3.9/ipaddress.py", line 53, in ip_address
    raise ValueError('%r does not appear to be an IPv4 or IPv6 address' %
ValueError: 'https' does not appear to be an IPv4 or IPv6 address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
    yield
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 101, in connect_tcp
    stream: anyio.abc.ByteStream = await anyio.connect_tcp(
  File "/usr/local/lib/python3.9/site-packages/anyio/_core/_sockets.py", line 152, in connect_tcp
    gai_res = await getaddrinfo(target_host, remote_port, family=family,
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 86, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 63, in handle_async_request
    stream = await self._connect(request)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 111, in _connect
    stream = await self._network_backend.connect_tcp(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/auto.py", line 23, in connect_tcp
    return await self._backend.connect_tcp(
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 101, in connect_tcp
    stream: anyio.abc.ByteStream = await anyio.connect_tcp(
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc)
httpcore.ConnectError: [Errno -3] Try again

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 335, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/loxone/__init__.py", line 156, in async_setup_entry
    if not await miniserver.async_setup():
  File "/config/custom_components/loxone/miniserver.py", line 118, in async_setup
    request_code = await self.lox_config.getJson()
  File "/config/custom_components/loxone/api.py", line 121, in getJson
    api_resp = await client.get("/jdev/cfg/apiKey")
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1729, in get
    return await self.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1506, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1593, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1621, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1658, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1695, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno -3] Try again

I've tried the local IP (with port 80 and 443) and the dns.loxonecloud.com address. Both do not work.

But the IP can be pinged successfully.

Andi

JoDehli commented 2 years ago

Next time please use the issue template. Which version do you have? Gen1 or 2?

If you have a gen 2 did you try the pyloxone beta?

AHub88 commented 2 years ago

I have a Gen2.

I've tried to install the beta over HACS, but it didn't work. I can't find the integration. There is only the PyLoxone (Master).

JoDehli commented 2 years ago

It is a complete different git repo. See your last post on issue number 104.

JoDehli commented 2 years ago

@AHub88 did you test it?

AHub88 commented 2 years ago

Unfortunately, I use Home Assistant with VMware. Therefore I don't know exactly how to replace the files. My Linux skills are not the best...

JoDehli commented 2 years ago

@AHub88 Did you get to the loxone web interface? You know the port of the loxone?

JoDehli commented 2 years ago

@AHub88 Did it already worked?

AHub88 commented 2 years ago

No it doesn't work. I have access to the web interface. The port is http (80) and https (443).

JoDehli commented 2 years ago

@AHub88 try a different port than 80. SSL access will not work (443). I changed mine to 8080 and connect via local access. So for host for example 192.168.1.20 and for port 8080. Of course you must change it first on the loxone itself.

I had in the past users which had problems on port 80. I never used port 80.

AHub88 commented 2 years ago

Now I've set in Loxone the port 8080 and restarted the server.

Unfortunately, the same problem. I can't connect over Home Assistant.

When I manually try the url 192.168.XX.XX:8080/jdev/cfg/apiKey over my browser, I get the right JSON.

JoDehli commented 2 years ago

@AHub88 can you give your VM where your home assistant is running a different IP. If you have to many failed connection attempts your IP will be banned and you 2ill get no explicit error message. I had this also in the past.

AHub88 commented 2 years ago

No it's working! There was a strange firewall setting in our network. THX for your support :)

Home Assistant can now establish a connection. However, errors occur when loading the entities :(

See Screen

image

Logger: homeassistant.components.switch
Source: custom_components/loxone/__init__.py:71
Integration: Schalter (documentation, issues)
First occurred: 20:15:01 (1 occurrences)
Last logged: 20:15:01

Error while setting up loxone platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/loxone/switch.py", line 22, in async_setup_entry
    miniserver = get_miniserver_from_config_entry(hass, config_entry)
  File "/config/custom_components/loxone/__init__.py", line 71, in get_miniserver_from_config_entry
    return hass.data[DOMAIN][config_entry.entry_id]
KeyError: '4e09fd6b9d3747fc841eca09528760d6'
JoDehli commented 2 years ago

@AHub88 Ok it seams your are using a old version of the pyloxone component. This error should not raise in the newest version. Please update to the newest version.

AHub88 commented 2 years ago

Now it works ! THX for the good support.