sdwilsh / hass-truenas

TrueNAS integration for Home Assistant
MIT License
39 stars 11 forks source link

TrueNAS scale #75

Open valgeirhelgi opened 2 years ago

valgeirhelgi commented 2 years ago

Hi! I'm having issues with using your integration with TrueNAS scale. I'm wondering if it could just be the fact that I'm using Scale. But here is the error.

2021-11-13 03:18:10 ERROR (MainThread) [custom_components.truenas.config_flow] Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.9/encodings/idna.py", line 165, in encode raise UnicodeError("label empty or too long") UnicodeError: label empty or too long The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/config/custom_components/truenas/config_flow.py", line 126, in async_step_auth_api_key info = await validate_input(self.hass, self._user_data) File "/config/custom_components/truenas/config_flow.py", line 54, in validate_input machine = await Machine.create( File "/usr/local/lib/python3.9/site-packages/aiotruenas_client/websockets/machine.py", line 48, in create await m.connect( File "/usr/local/lib/python3.9/site-packages/aiotruenas_client/websockets/machine.py", line 88, in connect await self._connect(auth_protocol, host, secure) File "/usr/local/lib/python3.9/site-packages/aiotruenas_client/websockets/machine.py", line 171, in _connect await connect( File "/usr/local/lib/python3.9/site-packages/websockets/legacy/client.py", line 622, in __await_impl__ transport, protocol = await self._create_connection() File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1017, in create_connection infos = await self._ensure_resolved( File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1396, in _ensure_resolved return await loop.getaddrinfo(host, port, family=family, type=type, File "/usr/local/lib/python3.9/asyncio/base_events.py", line 856, in getaddrinfo return await self.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, 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): UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

sdwilsh commented 2 years ago

TrueNAS claims that it's supposed to be the same API for both, but I've only tested it against Core, not Scale. It'll be awhile before I have the time to spin up a Scale VM to try and debug this.

With that said, it seems like the error is in Python before it even talks to the server, so I don't think it's a Scale vs Core issue: https://github.com/sdwilsh/hass-truenas/blob/main/custom_components/truenas/config_flow.py#L101

sdwilsh commented 2 years ago

Oh wait, that stack trace is backwards from what I'd expect. It is trying to talk to the server.

I think this is https://bugs.python.org/issue32958. I'm guessing you have a long hostname and long username/password?

valgeirhelgi commented 2 years ago

Hmm... I'm using the API key, because I get "Invalid Auth" if I try to use User/Pass.

valgeirhelgi commented 2 years ago

Ohhh yeah, my password is 16 characters and user is 7 char. Sorry forgot to let you know.

sdwilsh commented 2 years ago

Looking into this further, we don't use username@hostname to connect. The length of the password, username, and api key doesn't matter, since those are sent as a method over the websocket connection. Is your DNS name longer than 64 characters?

valgeirhelgi commented 2 years ago

I just have the default.

image

sdwilsh commented 2 years ago

v0.3.0 of this custom integration has some additional logging code which might help us figure out what is going on here. To do this, you'll want to update the logger integration with the following lines:

  logs:
    aiotruenas_client: debug
    custom_components.truenas: debug

Mine looks like this:

logger:
  default: info
  logs:
    aiotruenas_client: debug
    custom_components.truenas: debug