malkstar / ms_teams_websockets

Expose your Teams client's local websockets API data as Home Assistant sensors.
MIT License
16 stars 3 forks source link

Unexpected error #3

Open cvanover7 opened 1 year ago

cvanover7 commented 1 year ago

System Health details

System Information

version core-2023.5.3
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.10.11
os_name Linux
os_version 6.1.25
arch x86_64
timezone America/Chicago
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4967 Installed Version | 1.32.1 Stage | running Available Repositories | 1355 Downloaded Repositories | 14 HACS Data | ok
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | June 11, 2023 at 7:00 PM relayer_connected | true relayer_region | us-east-1 remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | true remote_server | us-east-1-5.ui.nabu.casa certificate_status | ready can_reach_cert_server | failed to load: timeout can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 10.1 -- | -- update_channel | stable supervisor_version | supervisor-2023.04.1 agent_version | 1.5.1 docker_version | 23.0.3 disk_total | 30.8 GB disk_used | 10.6 GB healthy | true supported | true board | ova supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.7.0), Cloudflared (4.1.5), File editor (5.6.0), Node-RED (14.1.5), Home Assistant Google Drive Backup (0.110.4), ESPHome (2023.4.4), Let's Encrypt (4.12.8), Ring-MQTT with Video Streaming (5.2.2), Mosquitto broker (6.2.1), Studio Code Server (5.5.7)
Dashboards dashboards | 1 -- | -- resources | 6 views | 7 mode | storage
Recorder oldest_recorder_run | May 12, 2023 at 3:47 PM -- | -- current_recorder_run | May 17, 2023 at 10:54 AM estimated_db_size | 123.58 MiB database_engine | sqlite database_version | 3.40.1

Checklist

Describe the issue

Upon submitting host/port/API token, I receive "Unexpected Error." Any hints on how to get additional debug information? Teams to Stream Deck works using the same API token.

Reproduction steps

  1. Install repo
  2. Add Integration
  3. Fill out the fields
  4. receive "Unexpected Error" ...

Debug logs

No logs available

Diagnostics dump

No response

malkstar commented 1 year ago

Apologies for leaving you on the hook! I'm not sure how my notification slipped past for this issue being raised (I use GH on a daily basis!)

I responded on the thread where I originally shared the repo, but what OS is your client on?

Either way, I'll spend some time improving the logging over the weekend to help, it is honestly currently non-existent.

loryanstrant commented 1 year ago

I also had an Unexpected Error, however mine was when trying to add a second device. Is that possible?

TarheelGrad1998 commented 1 year ago

I'm getting the same. I have next to zero permissions on my work/teams laptop, could that be why?

Otherwise, I've tried host name and IP but no luck. Bummer. :(

TarheelGrad1998 commented 1 year ago

Upon further research, it appears the organization has to have enabled the third party apps to connect. I'm certain my company has not allowed it, as they are the no fun club. :)

Oh well, a geek can dream...

adam-cobb commented 12 months ago

Seeing the same. Slightly confused as to what the host and port should be? Should it be left as localhost or is this HA hostname?

nikwilliamson commented 11 months ago

@TarheelGrad1998 and @adam-cobb, I figured it out.

Initially, I had the same suspicions about the integration being locked down. I see the "There are no allowed apps or devices" message too – but it was working in my Steam Deck.


Instructions

  1. On your WiFi router, assign a fixed IP address to your computer.
  2. Open up HomeAssistant and start your integration setup.
  3. Replace localhost with your local IP address.
  4. Enter your API token.
TarheelGrad1998 commented 11 months ago

Made no difference to me, I still get the error. I wasn't sure how that would but I'll try anything.

Below is what I get from the ha log, in case there is anything to be done about it.

Logger: custom_components.ms_teams_websockets.config_flow Source: custom_components/ms_teams_websockets/hub.py:38 Integration: Microsoft Teams (Local Websockets) (documentation, issues) First occurred: 10:37:47 AM (2 occurrences) Last logged: 10:50:56 AM

Unexpected exception Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 655, in await_impl_timeout return await self.await_impl() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 659, in await_impl _transport, _protocol = await self._create_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 628, in sock_connect return await fut ^^^^^^^^^ asyncio.exceptions.CancelledError

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

Traceback (most recent call last): File "/config/custom_components/ms_teams_websockets/config_flow.py", line 64, in async_step_user info = await validate_input(self.hass, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ms_teams_websockets/config_flow.py", line 45, in validate_input if not await ms_teams_hub.test_endpoint(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ms_teams_websockets/hub.py", line 38, in test_endpoint async with websockets.connect(self._uri) as websocket: File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 637, in aenter return await self ^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 654, in await_impl_timeout async with asyncio_timeout(self.open_timeout): File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in aexit raise TimeoutError from exc_val TimeoutError

Leseratte10 commented 11 months ago

I also get "Unexpected Error" when trying to connect, but with a different error in the logs - not sure if this is the same bug:

2023-10-11 10:37:11.810 ERROR (MainThread) [custom_components.ms_teams_websockets.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/ms_teams_websockets/config_flow.py", line 64, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ms_teams_websockets/config_flow.py", line 45, in validate_input
    if not await ms_teams_hub.test_endpoint():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ms_teams_websockets/hub.py", line 38, in test_endpoint
    async with websockets.connect(self._uri) as websocket:
  File "/config/lsiopy/lib/python3.11/site-packages/websockets/legacy/client.py", line 637, in __aenter__
    return await self
           ^^^^^^^^^^
  File "/config/lsiopy/lib/python3.11/site-packages/websockets/legacy/client.py", line 655, in __await_impl_timeout__
    return await self.__await_impl__()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/lsiopy/lib/python3.11/site-packages/websockets/legacy/client.py", line 662, in __await_impl__
    await protocol.handshake(
  File "/config/lsiopy/lib/python3.11/site-packages/websockets/legacy/client.py", line 329, in handshake
    raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 403