sdwilsh / hass-truenas

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

Initial setup throws unknown error (maybe related to UI port settings) #18

Open DrBlokmeister opened 3 years ago

DrBlokmeister commented 3 years ago

Update: when I enter the https port, it does allow me to complete the setup. I can now see the disk temperatures. I think it's a good idea to mention this in the install instructions.

I have TrueNAS configured to provide the UI on port 250 through http.

I tried to set up the integration this morning through the HA UI, but I'm getting an unknown error.

Things I have tried:

Error log:

2021-04-09 10:55:24 ERROR (MainThread) [custom_components.truenas.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/truenas/config_flow.py", line 121, 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.8/site-packages/aiotruenas_client/websockets/machine.py", line 43, in create
    await m.connect(
  File "/usr/local/lib/python3.8/site-packages/aiotruenas_client/websockets/machine.py", line 75, in connect
    await self._connect(auth_protocol, host, secure)
  File "/usr/local/lib/python3.8/site-packages/aiotruenas_client/websockets/machine.py", line 86, in _connect
    self._client = await websockets.connect(
  File "/usr/local/lib/python3.8/site-packages/websockets/client.py", line 535, in __await_impl__
    transport, protocol = await self._create_connection()
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 986, in create_connection
    infos = await self._ensure_resolved(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again
sdwilsh commented 3 years ago

Just to be clear, this worked correctly with the https port, but not the http port? Also, do you have "Web Interface HTTP -> HTTPS Redirect" checked under "System -> General"?

DrBlokmeister commented 3 years ago

Yes. It works with the https port. No, I don't have the redirect checked.

sdwilsh commented 3 years ago

I was able to get this error without any non-standard ports, and looking at logs, it looks like we were sending the hostname as the API key, but I don't see how that's even possible. I added some more logging, and restarted home assistant, and of course it worked :/

wijbrenv commented 3 years ago

API-Key works fine. I would say this is the way to connect. Username and password maybe a subject to two-factor authentications.