Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Getting a 409 error when trying to set up HW-Q950T #13

Open
PrMinisterGR opened this issue Feb 5, 2024 · 5 comments · May be fixed by #23
Open

[BUG] Getting a 409 error when trying to set up HW-Q950T #13

PrMinisterGR opened this issue Feb 5, 2024 · 5 comments · May be fixed by #23
Labels
bug Something isn't working

Comments

@PrMinisterGR
Copy link

PrMinisterGR commented Feb 5, 2024

Logger: homeassistant.config_entries
Source: config_entries.py:406
First occurred: 10:49:04 (7 occurrences)
Last logged: 11:10:00

Error setting up entry samsung_soundbar for samsung_soundbar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 406, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/samsung_soundbar/__init__.py", line 50, in async_setup_entry
    await soundbar_device.update()
  File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 49, in update
    await self._update_soundmode()
  File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 69, in _update_soundmode
    await self.update_execution_data(["/sec/networkaudio/soundmode"])
  File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 363, in update_execution_data
    return await self.device.command("main", "execute", "execute", argument)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/device.py", line 842, in command
    response = await self._api.post_device_command(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 147, in post_device_command
    return await self.post(API_DEVICE_COMMAND.format(device_id=device_id), data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 395, in post
    return await self.request("post", self._api_base + resource, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 376, in request
    resp.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 409, message='Conflict', url=URL('https://api.smartthings.com/v1/devices/{SOUNDBAR_DEVICE_ID}/commands')

I get the above when add the integration, the integrated Home Assistant Smart Things integration works, but I have no controls except power for my HW-Q950T Samsung soundbar.

@samuelspagl
Copy link
Owner

Hi @PrMinisterGR

You probably tried it out multiple times right? 😅 I know dumb question but still.

409 generally stands for a conflict or also for example if somebody is trying to create a resource thats already existing.

Do you think it would be possible for you to change something in the code, to see if that helps you?

You can get access to the config directory by using the "Visual Studio Code" Addon. You need to edit the SoundbarDevice.py file. The following is a short sketch of where to find it.

config
|- custom_components
  |- samsung_soundbar
    |- api_extension
      |- SoundbarDevice.py # This is the file you need to edit

In the update function could you please try to comment out (#) the following line

await self._update_soundmode()

and then try again?

@samuelspagl samuelspagl added the bug Something isn't working label Feb 8, 2024
@samuelspagl samuelspagl changed the title Getting a 409 error when trying to set up HW-Q950T [BUG] Getting a 409 error when trying to set up HW-Q950T Feb 8, 2024
@tjorim
Copy link
Contributor

tjorim commented Feb 8, 2024

I'm getting the same issue on a Q700C. Already tried commenting out the line as suggested. Modified from b2.

Logger: homeassistant.config_entries
Source: config_entries.py:442
First occurred: 00:46:04 (1 occurrences)
Last logged: 00:46:04

Error setting up entry samsung_soundbar for samsung_soundbar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 442, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/samsung_soundbar/__init__.py", line 50, in async_setup_entry
    await soundbar_device.update()
  File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 53, in update
    await self._update_advanced_audio()
  File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 133, in _update_advanced_audio
    await self.update_execution_data(["/sec/networkaudio/advancedaudio"])
  File "/config/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py", line 379, in update_execution_data
    return await self.device.command("main", "execute", "execute", argument)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/device.py", line 842, in command
    response = await self._api.post_device_command(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 147, in post_device_command
    return await self.post(API_DEVICE_COMMAND.format(device_id=device_id), data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysmartthings/api.py", line 395, in post
    return await self.request("post", self._api_base + resource, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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: 409, message='Conflict', url=URL('https://api.smartthings.com/v1/devices/my-own-random-code/commands')

@samuelspagl
Copy link
Owner

Okay, this really bugs me, because I'm not quite understanding why it's working for others but not for you guys.
Let's start from the beginning:
When you open the SmartThings App and tap on your Soundbar, what kind of settings can you set?

@tjorim
Copy link
Contributor

tjorim commented Feb 9, 2024

I noticed my soundbar was not connected to Wi-Fi anymore (also showed as offline in the app). I reset the soundbar and configured it again. I returned the source code to original (b3) and set it up. All working well for me! 👍

@samuelspagl
Copy link
Owner

Ah interesting good to know. Could @PrMinisterGR face the same issue of his soundbar not being connected with the wifi?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants