samuelspagl / ha_samsung_soundbar

YASSI (Yet another Samsung Soundbar integration) is a HomeAssistant integration for Samsung Soundbars.
https://ha-samsung-soundbar.vercel.app
MIT License
44 stars 2 forks source link

401 while adding Q990C #30

Closed cristhianerg closed 7 months ago

cristhianerg commented 7 months ago

Hey there, while adding a Q990C I'm getting 401 error despite of using a fresh generated token and device ID (I've chek that they work via postman)

Here's a sneak peek of the log (obviously the credentials are replaced)

2024-04-04 00:52:45.234 DEBUG (MainThread) [custom_components.samsung_soundbar.config_flow] Successfully validated Input, Creating entry with title samsung_soundbar and data {'api_key': MY_TOKEN_KEY, 'device_id': 'MY_DEVIDE_ID', 'device_name': 'Soundbar', 'device_volume': 100}
2024-04-04 00:52:45.236 INFO (MainThread) [custom_components.samsung_soundbar] [samsung_soundbar] Starting to setup a ConfigEntry
2024-04-04 00:52:45.236 DEBUG (MainThread) [custom_components.samsung_soundbar] [samsung_soundbar] Setting up ConfigEntry with the following data: {'api_key': 'MY_TOKEN_KEY', 'device_id': 'MY_DEVIDE_ID, 'device_name': 'Soundbar', 'device_volume': 100}
2024-04-04 00:52:45.236 DEBUG (MainThread) [custom_components.samsung_soundbar] [samsung_soundbar] Retrieved Domain Config: SoundbarConfig(api=<pysmartthings.smartthings.SmartThings object at 0x7f737911e0>, devices={})
2024-04-04 00:52:45.237 INFO (MainThread) [custom_components.samsung_soundbar] [samsung_soundbar] Setting up new Soundbar device
2024-04-04 00:52:45.237 DEBUG (MainThread) [custom_components.samsung_soundbar] [samsung_soundbar] DeviceId: MY_DEVIDE_ID not found in domain_config, setting up new device.
2024-04-04 00:52:45.300 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry samsung_soundbar for samsung_soundbar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/samsung_soundbar/__init__.py", line 42, in async_setup_entry
    smart_things_device = await domain_config.api.device(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/smartthings.py", line 92, in device
    entity = await self._service.get_device(device_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 121, in get_device
    return await self.get(API_DEVICE.format(device_id=device_id))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 380, in get
    return await self.request("get", self._api_base + resource, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 376, in request
    resp.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('https://api.smartthings.com/v1/devices/MY_DEVIDE_ID')
samuelspagl commented 7 months ago

Hi there āœŒļø

So first of all, the most important informations for me would be what version of the integration and HomeAssistant you are currently using.

And the "dumb" questions first šŸ˜…, the api_key and device_id in the logs matches the ones you used on postman?

samuelspagl commented 7 months ago

So I just checked my soundbar, and also Postman etc. and currently everything works fine for me. I'll try to help you as much as possible :)

cristhianerg commented 7 months ago

Hey @samuelspagl yes I've checked them and they match, I even can validate it following the URL in logs directrly in my browser...

My HA version is 2024.4.0, it is installed locally in my network on a RPi 4

cristhianerg commented 7 months ago

Maybe it has something to be with not having an installed SSL

cristhianerg commented 7 months ago

For the doubts I added a reverse proxy with SSL and still not working :( but now I got a different error, maybe you can share some light on this @samuelspagl

`2024-04-04 16:02:35.614 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry samsung_soundbar for samsung_soundbar Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/samsung_soundbar/init.py", line 52, in async_setup_entry await soundbar_device.update() File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 52, in update await self._update_soundmode() File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 74, in _update_soundmode payload = await self.get_execute_status() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 390, in get_execute_status return dict["data"]["value"]["payload"]


TypeError: 'NoneType' object is not subscriptable
`
samuelspagl commented 7 months ago

Yeah this error I can work with šŸ˜‚

Its the error that drives most of the users of my integration currently crazy, and the thing I can't do something about.

See #26 for the full description.

In short: on the 26th of March something changed on Samsung's side, therefore it is currently not possible to update / retrieve the status of custom capabilities (like soundmode, eq and more). While it is still possible to update the status of these, the retrieval doesn't work.

I released an alpha version of the integration where you can edit the entities created and therefore also stop the update process for these capabilities. Probably tomorrow I will release another alpha version that will include services for the custom capabilities.

I hope that sheds some light :)

cristhianerg commented 7 months ago

Thanks a lot for the quick answer. I'll try that on the beta

Cheers mate

samuelspagl commented 7 months ago

If you are fine with it, I would close your issue. Feel free to reopen it if anything still is unclear :)

Best Samuel